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

script is failing out after calling code that "loads NVM" after using wget or curl #1359

Open
ORESoftware opened this issue Dec 21, 2016 · 4 comments

Comments

@ORESoftware
Copy link

ORESoftware commented Dec 21, 2016

I have this bash script. What I want to do is have it run automatically, non-interactively...it installs NVM and then installs some modules globally.

#!/usr/bin/env bash

DIRN=$(dirname "$0")
echo " => SUMAN TEST PROJECTS => RUNNING '$DIRN'..."
echo " => PWD => $PWD"
OUTPUT_PATH=${PROJECT_ROOT:-$PWD}/npm-install-output.log &&
rm -rf $(dirname "$0")/node_modules &&
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash &&
export NVM_DIR="/root/.nvm" &&
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  && #  SEEMS TO FAIL HERE
echo "about to install node version 6 with NVM" &&
echo "path to nvm => $(which nvm)" &&
nvm install 6 &&
nvm use 6 &&
echo "about to run npm install --globally" &&
npm install -g github:oresoftware/suman#dev --unsafe-perm --loglevel=warn --progress=false &&
echo "done with npm install" &&
echo "running suman --init" &&
suman --init 

you should be able to run it on your system (feel free to sandbox it in a container or something if that suits your fancy).

Anyway, it errors out on the line that says # SEEMS TO FAIL HERE

Like I was saying earlier on another thread, I don't want this NVM install to be interactive at all....this script is for an automated test. But for some reason when I try to "load" NVM without starting a new terminal session, the script seems to conk out..any ideas?

@ljharb
Copy link
Member

ljharb commented Dec 21, 2016

You've got a whole lot of commands strung together with && - how do you know it's failing on that line? Is whoami root in this scenario? (also nvm use 6 is redundant after nvm install 6)

@ORESoftware
Copy link
Author

this might help, here is the stdio of script

=> nvm is already installed in /home/oleg/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> Source string already in /home/oleg/.bashrc
npm ERR! extraneous: moment@2.17.1 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/moment
npm ERR! extraneous: nightmare@2.9.0 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/nightmare
npm ERR! extraneous: selenium-webdriver@3.0.1 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/selenium-webdriver
npm ERR! extraneous: suman@1.1.512212 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/suman
npm ERR! invalid: suman-debug@0.0.104 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/suman-debug
npm ERR! invalid: suman-utils@0.0.73097 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/suman-utils
npm ERR! extraneous: webpage@0.3.0 /home/oleg/.nvm/versions/node/v7.2.1/lib/node_modules/suman/node_modules/webpage
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

/home/oleg/.nvm/versions/node/v7.2.1/lib
├── ava@0.17.0
├── create-react-app@1.0.2
├── gulp@3.9.1
├── lectal-meta@1.0.0 -> /home/oleg/WebstormProjects/the1mills/clone-all-org-repos
├── node-gyp@3.4.0
├── r.js@1.0.3
├── suman@1.1.512212 -> /home/oleg/WebstormProjects/oresoftware/sumanjs/suman
├── suman-debug@0.0.104 -> /home/oleg/WebstormProjects/oresoftware/sumanjs/suman-debug
├── suman-utils@0.0.73097 -> /home/oleg/WebstormProjects/oresoftware/sumanjs/suman-utils
├── webpack@1.14.0
└── yarn@0.17.10

=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:

     $ nvm use system
     $ npm uninstall -g a_module

=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="/home/oleg/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
 => bash exit code for script '/home/oleg/suman-test/suman-test-projects/subprojects/install-globally-with-nvm/test.sh' => 1

@ORESoftware
Copy link
Author

ORESoftware commented Dec 21, 2016

It seems like maybe NVM is forcing the process to close somehow? that doesn't make sense. I am not a shell scripting guru.

I took out the line where I source ~/.bash_profile, and I get the above output

It's exiting with code = 1, that is for sure

@ORESoftware
Copy link
Author

interesting, I ran this script in a container, vs. running it directly on my machine. It succeeds in a container, but fails when running direct. Not sure why...will investigate. Very strangely, nvm is available at the command line, but if I run the above script it will say, nvm is not an available command.

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

2 participants