apm icon indicating copy to clipboard operation
apm copied to clipboard

apm installed under WSL doesn't work correctly: "/opt/atom/resources/app/apm/bin/node.exe: No such file or directory"

Open bonotake opened this issue 6 years ago • 6 comments

Prerequisites

  • [X] Put an X between the brackets on this line if you have done all of the following:
    • Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
    • Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
    • Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
    • Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
    • Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages

Description

I have installed Atom under Ubuntu on Windows Subsystem for Linux (i.e. I installed it on WSL, not on Windows). But the commands apm doesn't work correctly so far. The first error occurred was: "/usr/bin/apm: line 46: /opt/atom/resources/app/apm/bin/node.exe: No such file or directory". I checked the code and reverted this commit so the error dissappeared.

Steps to Reproduce

  1. Open WSL (in my environment, Ubuntu) bash.
  2. Run sudo apt install atom.
  3. Download https://github.com/atom/atom/releases/download/v1.21.2/atom-amd64.deb.
  4. Run dpkg -i atom-amd64.deb.
  5. Run apm --version

Expected behavior: The version of apm should be appeared.

Actual behavior: The error below occurs:

/usr/bin/apm: line 46: /usr/share/atom/resources/app/apm/bin/node.exe: No such file or directory

Reproduces how often: 100%, every time.

Versions

$ atom --version
Atom    : 1.21.2
Electron: 1.6.15
Chrome  : 56.0.2924.87
Node    : 7.4.0

apm --version cannot be done, as I mentioned above.

Additional Information

I guess this commit is for following the WSL/Windows interoperability and running Windows' native Atom from WSL, but is it strange to install and use Atom on WSL side?

bonotake avatar Nov 05 '17 14:11 bonotake

Any fix on this? I have the same issue today.

ghost avatar May 07 '18 22:05 ghost

I installed atom in my Windows Subsystem for Linux Ubuntu 18.04, which have the same error.

To fix it, just remove the additions in this commit 10525a7bd6b3680d961f7db04e1eb8d7211afb63 as @bonotake mentioned:

$ cd /your/atom/installed/path 
$ vi  resources/app/apm/bin/apm  # if you install atom using apt-get install atom, it will be at: /usr/share/atom/resources/app/apm/bin/apm

My apm file changes (apm version: 1.19.0, atom version 1.27.2) : change1: replace node.exe with node at line 17. change2: comment line 56 to line 61.

Before:

# Detect node binary name
osName=`uname -s`
if [ "${osName:0:10}" == 'MINGW32_NT' ]; then
  nodeBin="node.exe"
elif [[ $(uname -r) == *-Microsoft ]]; then
  nodeBin="node.exe" 
else
  nodeBin="node"
fi
...

cliPath="$binDir/../lib/cli.js"
if [[ $(uname -r) == *-Microsoft ]]; then
  cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')"
  cliPath="${cliPath////\\}"
else
  builtin cd "$initialCwd"
fi

After:

# Detect node binary name
osName=`uname -s`
if [ "${osName:0:10}" == 'MINGW32_NT' ]; then
  nodeBin="node.exe"
elif [[ $(uname -r) == *-Microsoft ]]; then
  nodeBin="node"  #change 1:  remove  ".exe"
else
  nodeBin="node"
fi
...

cliPath="$binDir/../lib/cli.js"
# change 2: comment below lines
#if [[ $(uname -r) == *-Microsoft ]]; then
#  cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')"
#  cliPath="${cliPath////\\}"
#else
builtin cd "$initialCwd"
#fi

genshen avatar Jun 11 '18 14:06 genshen

took me 2 hrs. to resolve this issue today - the fix worked for me under WSL w/ Ubuntu- Bionic Beaver- thx!!!

$ apm --version apm 1.19.0 npm 3.10.10 node 6.9.5 x64 atom 1.29.0 python 3.6.4 git 2.18.0

well done, @genshen!!

realjkg avatar Aug 22 '18 04:08 realjkg

Thank You. For people who want to conquer WSL, give me a shout because I have a full working xfce4 GUI and lots of other cool things actually working in it now.

diveyez avatar Apr 29 '19 18:04 diveyez

I applied the changes to the file /usr/bin/apm:

#!/bin/bash

set -e

initialCwd=`pwd -P`
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

apmPath=$0
builtin cd "`dirname "$apmPath"`"
binDir=`basename "$apmPath"`

# Detect node binary name
osName=`uname -s`
if [ "${osName:0:10}" == 'MINGW32_NT' ]; then
  nodeBin="node.exe"
elif [[ $(uname -r) == *-Microsoft ]]; then
  nodeBin="node"  #change 1:  remove  ".exe"
else
  nodeBin="node"
fi

cliPath="$binDir/../lib/cli.js"
# change 2: comment below lines
#if [[ $(uname -r) == *-Microsoft ]]; then
#  cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')"
#  cliPath="${cliPath////\\}"
#else
builtin cd "$initialCwd"
#fi


# Force npm to use its builtin node-gyp
unset npm_config_node_gyp

export ATOM_APM_ORIGINAL_PYTHON="${PYTHON:-}"

# Assumption: env iterates through environment variables in the same order that
# process.env iterates through properties within npm. So, we take the last match.
for var in $(env | grep -i ^npm_config_python=)
do
  ATOM_APM_ORIGINAL_PYTHON="${var#*=}"
  unset ${var%%=*}
done

export npm_config_python="${binDir}/python-interceptor.sh"

cliPath="$binDir/../lib/cli.js"
if [[ $(uname -r) == *-Microsoft ]]; then
  cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')"
  cliPath="${cliPath////\\}"
else
  builtin cd "$initialCwd"
fi

"$binDir/$nodeBin" "$cliPath" "$@"

And I am getting the following error:

neo@DESKTOP-R88JKVQ:/mnt/c/WINDOWS/system32$ apm --version
/usr/bin/apm: line 55: apm/node: No such file or directory

freeman42x avatar Aug 21 '19 13:08 freeman42x

thank. my changed file.

#!/bin/bash

set -e

initialCwd=`pwd -P`
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

apmPath=$0
builtin cd "`dirname "$apmPath"`"
binDir=`basename "$apmPath"`

# Detect node binary name
osName=`uname -s`
if [ "${osName:0:10}" == 'MINGW32_NT' ]; then
  nodeBin="node.exe"
elif [[ $(uname -r) == *-Microsoft ]]; then
  if [ "${osName:0:5}" == 'Linux' ]; then
    nodeBin="node"
  else
    nodeBin="node.exe"
  fi
else
  nodeBin="node"
fi

while [ -L "$binDir" ]
do
  binDir=`readlink "$binDir"`
  builtin cd "`dirname "$binDir"`"
  binDir=`basename "$binDir"`
done

binDir=`pwd -P`

# Force npm to use its builtin node-gyp
unset npm_config_node_gyp

cliPath="$binDir/../lib/cli.js"
if [[ $(uname -r) == *-Microsoft ]]; then
  if [ "${osName:0:5}" == 'Linux' ]; then
    builtin cd "$initialCwd"
  else
    cliPath="$(echo $cliPath | sed 's/\/mnt\/\([a-z]*\)\(.*\)/\1:\2/')"
    cliPath="${cliPath////\\}"
  fi
else
  builtin cd "$initialCwd"
fi

"$binDir/$nodeBin" "$cliPath" "$@"

vcmania avatar Jan 22 '21 10:01 vcmania