Truffle: compile and test don't work on Windows

Created on 29 May 2017  路  4Comments  路  Source: trufflesuite/truffle

Issue

Both truffle compile and truffle test don't work on Windows, in the default demo project (on [email protected] which is the version known to work on Windows).

Steps to Reproduce

truffle init
truffle compile   (or truffle test)

Expected Behavior

Compilation of the project

Actual Results

My IDE (VSCode) opens with the file truffle.js.
I believe truffle script intends to run truffle.js in some way, but instead what happens is just the file is opened on IDE, and the truffle commands returns.

Environment

  • Operating System: Windows 10
  • Truffle version: 3.2.1

Most helpful comment

This issue is discussed in the docs here. You can rename truffle.js to truffle-config.js.

If that doesn't fix your issue, please reopen. Thanks!

All 4 comments

I'm happy to report that both work well on Bash on Ubuntu on Windows. Keep this bug open for now in case we want to someday enable it to work on true Windows cmd.

This issue is discussed in the docs here. You can rename truffle.js to truffle-config.js.

If that doesn't fix your issue, please reopen. Thanks!

Tried renaming to truffle-config.js, and it didn't resolve the issue.
(truffle compile now just doesn't do anything).

This is not releated to Windows in general: if you use Power Shell or other terminals (i.e. the one integrated into Visual Studio Code, Bash, etc.) the problem does not appear. It happens with cmd.exe because the command line takes into consideration the PATHEXT enviroment variable.

For example, a common PATHEXT value at system level is:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

This tells Windows to consider files with those extensions as executables. When you run the truffle command inside your project folder, _truffle.js_ takes the precedence and it _starts_. This means that, if you assigned for example a default text editor to .js file, when you type truffle inside the project folder the truffle.js file is opened inside the default text editor.

To get rid of this particular problem, you can override the default PATHEXT system environment variable with a user environment variable, removing the .JS extension from the admitted values.

IMHO it's better to use a _safer_ PATHEXT in any case. For example, I use this:

PATHEXT=.COM;.EXE;.BAT;.CMD;.MSC

Was this page helpful?
0 / 5 - 0 ratings