vagrant bootstrap: source ~/.profile not working - vagrant

So I'm trying to install nvm and node in vagrant but can't seem to make it work.
Apparently I'm having trouble getting it to load/read nvm since nvm requires you to reload your terminal. ~/.profile doesn't seem to be doing the job
using ubuntu/xenial64
This is my bootstrap.sh file
#install nvm
cd ~
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh -o install_nvm.sh
bash install_nvm.sh
#this command makes it so that you don't need to re-open the terminal for 'nvm' to be available
source ~/.profile
#use nvm to install node
nvm install 6.2.2
nvm use 6.2.2
the error I get (slightly modified to hide personal information):
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /installation_data => C:/work/<PATH_OMMITED>
==> default: Running provisioner: shell...
default: Running: C:/Users/ahmed/AppData/Local/Temp/vagrant-shell20160703-8248-1c82peg.sh
==> default: => Downloading nvm from git to '/home/ubuntu/.nvm'
=> default:
==> default: Cloning into '/home/ubuntu/.nvm'...
==> default: * (HEAD detached at v0.31.2)
==> default: master
==> default: => Appending source string to /home/ubuntu/.bashrc
==> default: => Close and reopen your terminal to start using nvm
==> default: /tmp/vagrant-shell: line 11: nvm: command not found
==> default: /tmp/vagrant-shell: line 12: nvm: command not found
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Instead of sourcing ~/.profile try this:
echo "--- Installing Node.js ---"
git clone https://github.com/creationix/nvm.git /home/vagrant/.nvm && cd /home/vagrant/.nvm && git checkout `git describe --abbrev=0 --tags`
source /home/vagrant/.nvm/nvm.sh
nvm install 6.2.2
nvm use 6.2.2
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
echo $n
Please refer this post. Tested on scotch box. Seems to just work fine.

Related

I can't install RVM and Ruby on Vagrant (box "hashicorp/precise64")

everyone! I've followed the instructions from https://rvm.io/integration/vagrant
So in Vargantfile I have:
config.vm.box = "hashicorp/precise64"
config.vm.provision :shell, path: "provision/install-rvm.sh", args: "stable", privileged: false
config.vm.provision :shell, path: "provision/install-ruby.sh", args: "1.9.3", privileged: false
config.vm.provision :shell, path: "provision/install-ruby.sh", args: "2.0.0 rails haml", privileged: false
in install-rvm.sh:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s $1
in install-ruby.sh:
source $HOME/.rvm/scripts/rvm || source /etc/profile.d/rvm.sh
rvm use --default --install $1
shift
if (( $# ))
then gem install $#
fi
rvm cleanup all
but after vagrant up it says:
==> default: gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
==> default: gpg: key D39DC0E3: "Michal Papis (RVM signing) <mpapis#gmail.com>" not changed
==> default: gpg: Total number processed: 1
==> default: gpg: unchanged: 1
==> default: /tmp/vagrant-shell: line 4: curl: command not found
==> default: Running provisioner: shell...
default: Running: /tmp/vagrant-shell20170120-19193-117iyxj.sh
==> default: /tmp/vagrant-shell: line 3: /usr/local/rvm/scripts/rvm: No such file or directory
==> default: /tmp/vagrant-shell: line 3: /etc/profile.d/rvm.sh: No such file or directory
==> default: /tmp/vagrant-shell: line 5: rvm: command not found
==> default: /tmp/vagrant-shell: line 13: rvm: command not found
But if I run the same provision with rvm and ruby on "ubuntu/trusty64"
everything works just fine
RVM depends on curl - add extra line to install curl like:
apt-get install curl
before any calls to rvm scripts

Vagrant box could not be found or could not be accessed in the remote catalog - incompatible curl version

I just downloaded Vagrant and did the settings as well as install virtual box. I just can't start my project (vagrant up). I have a vagrant file and so on. What can I do?
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'scotch/box' could not be found. Attempting to find and install
...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'scotch/box' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/scotch/box"]
There seems to be an issue with vagrant 1.8.7 and the embedded curl version vs the mac os binary (shipped by default on mac os Sierra and others) - remove the embedded one
sudo rm /opt/vagrant/embedded/bin/curl
Note: you also need to remove the embedded curl when you add a vagrant box (remotely or locally) so if you get the same error when running vagrant box add .... just remove the curl from vagrant and it will work
Just wanted to update this post. I ran into this error running macOS Sierra and a fresh Vagrant 1.8.7 install and noticed Vagrant just updated. As of Vagrant 1.9.0 this error appears to have been fixed.
Had a similar problem with Sierra (with additional brew installs - which granted could have an impact).
Above sudo rm /opt/vagrant/embedded/bin/curl did not work still got: SSLRead() return error -36.
Tried suggestion from http://slick.pl/kb/software/vagrant-fix-for-error-60-ssl-read/
Any case:
cd ~
cd .vagrant.d/tmp/
rm -rf ~/.vagrant.d/tmp/
vagrant box add --insecure laravel/homestead
Installed successfully.
I just experienced this error.
In my case I installed vagrant via apt-get which installed 1.7.x..
I removed 1.7.x and installed 2.0.3 directly https://www.vagrantup.com/downloads.html
I had this same problem on MacOS Mojave, and Vagrant version 1.9.3, when trying to use the box: centos/7.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'centos/7' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/centos/7"]
Error: The requested URL returned error: 404 Not Found
I updated to Vagrant 2.2.5 and it worked as expected:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
default: URL: https://vagrantcloud.com/centos/7
==> default: Adding box 'centos/7' (v1902.01) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box
default: Download redirected to host: cloud.centos.org
==> default: Successfully added box 'centos/7' (v1902.01) for 'virtualbox'!
You should try update Vagrant to the latest version:
sudo add-apt-repository ppa:tiagohillebrandt/vagrant
sudo apt update
This will add a repository for your actual ubuntu version. If you are on 20.10 (groovy) replace groovy with focal and call sudo apt update again.
Then install vagrant again:
sudo apt install vagrant
And update all plugins:
vagrant plugin update

Tried installing MongoDB with brew and it says "Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)"

Using Mac OSX 10.10.4 on 13' Macbook Air
Typed in 'brew update' like the Mongo docs said and it updated
Then typed 'brew install mongodb' and it took ages to say
Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)
This is what the console said leading up to that point, in case this helps:
Joshuas-Air:~ Josh$ brew install mongodb
==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.0.4.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mongodb-3.0.4.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/mongod.conf
Warning: Bottle installation failed: building from source.
==> Installing mongodb dependency: scons
==> Downloading https://homebrew.bintray.com/bottles/scons-2.3.5.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring scons-2.3.5.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/scons/2.3.5: 208 files, 2.4M
==> Downloading https://fastdl.mongodb.org/src/mongodb-src-r3.0.4.tar.gz
######################################################################## 100.0%
==> Cloning https://github.com/mongodb/mongo-tools.git
Updating /Library/Caches/Homebrew/mongodb--github.com-mongodb-mongo-tools--git
==> Checking out tag r3.0.4
==> ./build.sh
==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/3.0.4 -j4 --osx-version-min=10.10 --cc=/usr/bin/clang --cxx=/usr/bin/clang++ --use-new-tools
Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)
Joshuas-Air:~ Josh$
Any help at all would be appreciated.
I had mostly the same error. I could not solve the problem by chown'ing the /usr/local directories as the prompts suggest possibly due to my upgrade to High Sierra. I was able to succeed installing mongodb by reinstalling homebrew using the following command:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This allowed my subsequent brew install mongodb to work.
I had the same problem, changing the directory permissions didn't work for me so eventually I've found this solution:
Download the most recent version (.tgz).
Open the terminal and head to the ~/Downloads folder or wherever you saved the file.
Untar: tar xvf filename.tgz.
Enter the directory and go to the bin directory.
At the terminal use the sudo bash (become root) command.
Now enter the command cp * /usr/local/bin.
Create /data/db directories (optional, this is the default location MongoDB uses).
At the terminal use the command exit to exit root user.
which mongo should now respond with /usr/local/bin and you are all set to go.
My guess is that the permissions on the folder /usr/local/ are not set 755 or 777.
You can change the permissions or simply try to run the command as root:
sudo brew install mongodb

Vagrant provision not working

I have a problem with installing softwares using the vagrant provisions . I just tried to install git but I get this error :
==> default: stdin: is not a tty
==> default: git-email git-gui gitk gitweb diffutils-doc
==> default: The following NEW packages will be installed:
==> default: git git-man liberror-perl patch
==> default: 0 upgraded, 4 newly installed, 0 to remove and 179 not upgraded.
==> default: Need to get 6,730 kB of archives.
==> default: After this operation, 15.4 MB of additional disk space will be used.
==> default: Do you want to continue [Y/n]?
==> default: Abort.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
my Vargantfile looks so :
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.provision "shell", path: "bootstrap.sh"
end
and my bootstrap.sh contains exactly :
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install git
I tried it on mac and windows and get the same errors , I am using vagrant 1.7.2
You need to add the -y flag when installing stuff from your bootstrap file, otherwise the system will wait for a confirmation
sudo apt-get -y install git

using Vagrant getting a shell script issue and failure

I have the following details:
Vagrant File:
Vagrant.configure("2") do |config|
config.vm.box = "Precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.synced_folder "./Public","/var/www/",create:true
config.vm.network :private_network, ip: "192.168.55.55"
config.vm.provision :shell, :path => "setup.sh"
end
Shell File:
sudo apt-get -y update
sudo apt-get install apache2 php5 libapache2-mod-php5
sudo sudo apachectl restart
The shell is s little limited but i want to get it to work first before i attempt all the other php stuff etc
The error i get starts here:
Do you want to continue [Y/n]? Abort.
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell
Stdout from the command:
then continues with trying to get or hit files
Fetched 3,018 kB in 4s (681 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
Suggested packages:
www-browser apache2-doc apache2-suexec apache2-suexec-custom
openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
0 upgraded, 10 newly installed, 0 to remove and 155 not upgraded.
Need to get 1,845 kB of archives.
After this operation, 5,314 kB of additional disk space will be used.
Do you want to continue [Y/n]? Abort.
Stderr from the command:
stdin: is not a tty
i have even tried:
config.vm.network :forwarded_port, host: 3003, guest: 3000
And thats it failure, althought when i do go to localhost:3000 or that i get:
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
Protocol mismatch.
I am on a MAC OSX 10.8.5
also the sections where it say
Do you want to continue [Y/n]?
i don't get to choose it automatically does this for me.
Can you try adding a '-y' to apt-get install? like: sudo apt-get -y install apache2 php5 libapache2-mod-php5 to overcome the 'Do you want to continue [Y/n]'? - nikhil

Resources