Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember start-up script failing on windows #9190

Closed
albertodiazdorado opened this issue Apr 26, 2020 · 3 comments
Closed

ember start-up script failing on windows #9190

albertodiazdorado opened this issue Apr 26, 2020 · 3 comments

Comments

@albertodiazdorado
Copy link

albertodiazdorado commented Apr 26, 2020

Steps to reproduce:

  1. Install git bash https://gitforwindows.org/
  2. Install node https://nodejs.org/en/download/
  3. (Fix your path by adding export PATH=$PATH:"C:\Program Files\nodejs" to .bashrc)
  4. Install ember-cli npm install -g ember-cli
  5. (Fix your path by adding export PATH=$PATH:"C:\Users\USUARIOPC\AppData\Roaming\npm" to your .bashrc)
  6. Run ember -v

Expected behaviour: Prints the ember-cli version

Actual behaviour:

$ ember -v
internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\Git\Users\USUARIOPC\AppData\Roaming\npm\node_modules\ember-cli\bin\ember'
?[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:862:27)?[39m
?[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)?[39m
?[90m    at internal/main/run_main_module.js:18:47?[39m {
  code: ?[32m'MODULE_NOT_FOUND'?[39m,
  requireStack: []
}

The problem is that the emberstartup script is trying to load ember-cli from the wrong path. There is nothing under 'C:\Program Files\Git\Users\USUARIOPC\AppData\Roaming\npm\node_modules\ember-cli\bin\ember. That path does not even exist. In the startup script, located at C:\Users\USUARIOPC\AppData\Roaming\npm\ember, we have the following code:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/ember-cli/bin/ember" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/ember-cli/bin/ember" "$@"
  ret=$?
fi
exit $ret

And cygpath is giving the wrong the path. After some logging, I figured out the problem is:

$ cygpath -w "/Users/USUARIOPC/AppData/Roaming/npm"
C:\Program Files\Git\Users\USUARIOPC\AppData\Roaming\npm

Is this a problem we have to fix at ember-cli, or is it a problem with my system? My first temptation is to edit the C:\Users\USUARIOPC\AppData\Roaming\npm\ember to fix the path loading, in which case I may as well submit a PR, but I am not sure whether that is the rigth approach. It may be that I am doing something very wrong, since I do not usually use windows for coding tasks.

Thanks for any help!


If I hard-code the path by writing

case `uname` in
    # *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
    *CYGWIN*|*MINGW*|*MSYS*) basedir="C:\Users\USUARIOPC\AppData\Roaming\npm";;
esac

Then I get this output, which looks fine:

$ ember -v
ember-cli: 3.17.0
node: 12.16.2
os: win32 x64
@kellyselden
Copy link
Member

Can you send us the output of npx cross-env DEBUG=ember-cli:bin ember v?

@albertodiazdorado
Copy link
Author

Sure, here it is. Thanks for the super quick response!

$ npx cross-env DEBUG=ember-cli:bin ember v
npx: instaló 7 en 3.486s
  ember-cli:bin Resolving "ember-cli" from "C:\\Users\\USUARIOPC\\Documents\\EmberJS"... +0ms
  ember-cli:bin Resolved "ember-cli" to undefined +5ms
  ember-cli:bin Loading "ember-cli"... +0ms
  ember-cli:bin Starting "ember-cli"... +263ms
ember-cli: 3.17.0
node: 12.16.2
os: win32 x64
  ember-cli:bin Quitting "ember-cli" with exit code: undefined +3s

Copy link
Member

rwjblue commented Apr 27, 2020

Is this a problem we have to fix at ember-cli, or is it a problem with my system?

FWIW, the script you are showing is not created by ember-cli at all, it is created by npm your package manager when you do a global install (e.g. npm install -g ember-cli).

@locks locks closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants