vscode-ext
vscode-ext copied to clipboard
Build command does not find contract to build
Trying to build a contract from the GUI results in a "Everything is up to date, there is nothing to compile" message and the contract does not compile. It's as though truffle doesn't recognize that the file is located in the ./contracts/
folder.
Running the exact GUI-specific command from the CLI provides the same result, but:
- running the GUI-specific command from the CLI and omitting the file name causes all contracts to build successfully.
- running the GUI-specific command from the CLI and prepending the file name with "./contracts/" causes the individual contract to build as expected.
Once the contracts are built, there is never an option to deploy them when I right click on the contract.
- Truffle for VS Code Extension version: 2.7.1
- Dev Environment: Windows 11 Pro / WSL2:Ubuntu 22.04
GUI output
[Truffle: Requirements] Get version for required apps: truffle
[Truffle: Requirements] Current state for versions: [{"app":"node","isValid":true,"requiredVersion":{"max":"19.0.0","min":"14.0.0"},"version":"18.15.0"},{"app":"npm","isValid":true,"requiredVersion":{"max":"9.0.0","min":"6.14.15"},"version":"8.19.4"},{"app":"git","isValid":true,"requiredVersion":"2.10.0","version":"2.34.1"},{"app":"truffle","isValid":true,"requiredVersion":{"max":"6.0.0","min":"5.0.0"},"version":"5.8.0"},{"app":"ganache","isValid":true,"requiredVersion":{"max":"8.0.0","min":"7.4.3"},"version":"7.7.6"}] Invalid: false
[Truffle: Execute command]
Working dir: /home/***/blockchains/evm
Running command
npx truffle compile --config truffle-config.js WithdrawalContract.sol
[Truffle: Execute command]
Compiling your contracts...
[Truffle: Execute command] ===========================
[Truffle: Execute command] > Compiling WithdrawalContract.sol
[Truffle: Execute command] > Everything is up to date, there is nothing to compile.
[Truffle: Execute command] Finished running command
Hey @jem-Solytica, apologies for the slight delay in getting to this one! First up, regarding the contracts apparently not building it sounds like it could be related to the slightly confusing UX in that if you right-click on a contract, the context menu ("Build This Contract", see below) only targets that contract alone vs all of the contracts in the directory.
To get it to build all the contracts you need to right-click on the containing directory above or the play-like button above the explorer view (examples of both below). Again, this is possibly a little confusing and something we'll likely change going forward.
Regarding deployment, again it's a case of right-clicking the top-level directory or the broadcast icon on the menu above.
Apologies for the potential confusion here and let us know if any further questions. 👍
Appreciate the detailed response, but perhaps I was unclear. I am trying to build a single contract via the context menu in the Truffle extension, which is failing. Apologies in advance for the long message that follows but figured a picture (or ten) would be worth a thousand words....
I created a new project to make sure I could replicate the issue. Bootstrap was a "Create sample project"
Output:
[Truffle: Requirements] Get version for required apps: truffle
[Truffle: Requirements] Current state for versions: [{"app":"node","isValid":true,"requiredVersion":{"max":"19.0.0","min":"14.0.0"},"version":"18.15.0"},{"app":"npm","isValid":true,"requiredVersion":{"max":"9.0.0","min":"6.14.15"},"version":"8.19.4"},{"app":"git","isValid":true,"requiredVersion":"2.10.0","version":"2.34.1"},{"app":"truffle","isValid":true,"requiredVersion":{"max":"6.0.0","min":"5.0.0"},"version":"5.8.0"},{"app":"ganache","isValid":true,"requiredVersion":{"max":"8.0.0","min":"7.4.3"},"version":"7.7.6"}] Invalid: false
[Truffle: Execute command]
Working dir: /home/jem/dev/truffle_test/src
Running command
npx truffle compile --config truffle-config.js HelloBlockchain.sol
[Truffle: Execute command]
Compiling your contracts...
[Truffle: Execute command] ===========================
[Truffle: Execute command] > Compiling HelloBlockchain.sol
[Truffle: Execute command] > Everything is up to date, there is nothing to compile.
[Truffle: Execute command] Finished running command
As you can see below, the build/contracts directory is created, but is empty (no built contract).
Exact same result/output with the "Build Contracts" from the Explorer panel:
Contrast that with the "Build Contracts" right click on the "contracts" within the Truffle extension's "Contract Explorer" panel, and I get a different (expected) result:
Output:
[Truffle: Requirements] Get version for required apps: truffle
[Truffle: Requirements] Current state for versions: [{"app":"node","isValid":true,"requiredVersion":{"max":"19.0.0","min":"14.0.0"},"version":"18.15.0"},{"app":"npm","isValid":true,"requiredVersion":{"max":"9.0.0","min":"6.14.15"},"version":"8.19.4"},{"app":"git","isValid":true,"requiredVersion":"2.10.0","version":"2.34.1"},{"app":"truffle","isValid":true,"requiredVersion":{"max":"6.0.0","min":"5.0.0"},"version":"5.8.0"},{"app":"ganache","isValid":true,"requiredVersion":{"max":"8.0.0","min":"7.4.3"},"version":"7.7.6"}] Invalid: false
[Truffle: Execute command]
Working dir: /home/jem/dev/truffle_test/src
Running command
npx truffle compile --config truffle-config.js
[Truffle: Execute command]
Compiling your contracts...
[Truffle: Execute command] ===========================
[Truffle: Execute command] > Compiling ./contracts/HelloBlockchain.sol
[Truffle: Execute command] > Compilation warnings encountered:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> project:/contracts/HelloBlockchain.sol
[Truffle: Execute command] > Artifacts written to /home/jem/dev/truffle_test/src/build/contracts
> Compiled successfully using:
[Truffle: Execute command] - solc: 0.8.13+commit.abaa5c0e.Emscripten.clang
[Truffle: Execute command] Finished running command
And the built contract appears in the build/contracts
folder:
The only workaround I've been able to use for a single contract is to revise this command from the failing build output:
npx truffle compile --config truffle-config.js HelloBlockchain.sol
and then manually run it from the command line but with the full (relative) path to the contract file, like so:
npx truffle compile --config truffle-config.js ./contracts/HelloBlockchain.sol
Hey again @jem-Solytica, thanks so much for the detailed repo steps! I'm able to reproduce on my side and it's definitely an issue.
I've also done a bit of digging and the issue is occurring here...it looks like it might be a regression that got introduced as from memory it used to work.
Great that you have a workaround in the interim and we'll aim to get it addressed asap!
Thanks again 👍