I am simply trying to install passenger for nginx but installing the passenger gem fails. Here's what I have in my recipe:
rvm_gem "passenger" do
ruby_string "ruby-1.9.3-p194#env"
action :install
end
# install nginx for rails
execute "passenger_module1" do
user "#{node[:user][:name]}"
environment ({'HOME' => "/home/#{node[:user][:name]}"})
command "rvmsudo passenger-install-nginx-module --auto | bash"
action :run
end
Here's the Error message:
[2012-12-10T01:05:52+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: rvm_gem[passenger] (main::default line 127) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of bash -c "source /etc/profile.d/rvm.sh && rvm version | cut -d ' ' -f 2" ----
STDOUT:
STDERR: bash: /etc/profile.d/rvm.sh: No such file or directory
---- End output of bash -c "source /etc/profile.d/rvm.sh && rvm version | cut -d ' ' -f 2" ----
Ran bash -c "source /etc/profile.d/rvm.sh && rvm version | cut -d ' ' -f 2" returned 1
I don't see any issues with your Chef recipe fragment. The error message indicates that the execution of rvm in the shell is failing, because /etc/profile.d/rvm.sh does not exist.
This makes me think that you may not have rvm installed on this node. Did you install rvm on the node?
If you did, did you do it in a way that made it immediately available for use in your Chef run?
Related
I'm trying to install Ruby 2.6.1 on Ubuntu but keep coming across this error.
Have tried uninstalling Ubuntu, googling the problem, running in administrator mode, downloading a different version.
This is the error:
:~$ rvm install 2.6.1
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.1.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
mkdir: cannot create directory ‘/usr/share/rvm/log/1625135668_ruby-2.6.1’: Permission denied
tee: /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log: No such file or directory
Updating system..jaydene password required for 'apt-get --quiet --yes update':
Sorry, try again.
jaydene password required for 'apt-get --quiet --yes update':
..
Error running 'requirements_debian_update_system ruby-2.6.1',
please read /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log
Requirements installation failed with status: 1.
:~$
you can use a gorails website to checkout ruby on rails installation. And ruby installs version as per dependencies on your system. If it's not founding 2.6.1 it will install next supported version for ex. 2.6.7.
check this website: https://gorails.com/setup/ubuntu/21.04
Check this: How do I install Ruby 1.9.3 on Ubuntu without RVM? but SO says to avoid link answers so here is the script:
#!/usr/bin/env bash
# -- this really is the only solution that worked for me on snap :/
ruby -v
if ! command -v ruby &> /dev/null
then
echo "Going to try to install ruby (ideally 3.1.2)"
# - install rebenv (following ruby-build really is needed eventhough it doesn't look like it)
mkdir -p ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
# if $HOME/.rbenv/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ ":$PATH:" != *":$HOME/.rbenv/bin:"* ]]; then
echo "might want to put $HOME/.rbenv/bin in your path"
export PATH="$HOME/.rbenv/bin:$PATH"
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.lfs
fi
eval "$(rbenv init -)"
rbenv -v
# - install ruby-build, odd, this really is needed for ruby to install despite it not looking like ruby build is need at the bottom
mkdir -p ~/.ruby-build
cd ~/.ruby-build
git clone https://github.com/rbenv/ruby-build.git .
# if $HOME/.ruby-build/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ $PATH != *"$HOME/.ruby-build/bin"* ]]; then
echo "might want to put $HOME/.ruby-build/bin in your path"
export PATH="$HOME/.ruby-build/bin:$PATH"
# echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.lfs
fi
ruby-build --version
# - install ruby without sudo -- using rbenv
mkdir -p ~/.local
# ruby-build 3.1.2 ~/.local/
rbenv install 3.1.2
rbenv global 3.1.2
fi
ruby -v
# - Original Prover doesn't work on SNAP
# Proverbot's way to install ruby
# # First, install Ruby, as that is for some reason required to build the "system" project
# git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local ./ruby-build/install.sh
# ~/.local/ruby-build 3.1.2 ~/.local/
# ref: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby/1756372#1756372
For some shell script I need to store output of command -v foo in variables. I am checking if some binaries exist on the system. When I execute command -v foo in terminal, I get an output but when I execute command -v foo inside a shell script I don't get any output.
➜ tools git:(install-script) ✗ command -v node
/usr/local/bin/node
check_deps() {
declare -A deps
deps=( ['git']=`command -v git`
['gem']=`command -v gem`
['node']=$(command -v node))
# ['redis-server']=command -v redis-server
# ['postgres']=command -v psql
# ['sass']=command -v sass
# ['gulp']=command -v gulp
# ['bower']=command -v bower )
for each in ${!deps[#]};
do
echo $each ${deps[$each]}
done
}
check_deps
Output is:
node
git /usr/bin/git
gem /usr/bin/gem
[Finished in 0.0s]
What's happening? How do I fix this?
I was using Sublime Text which had a plugin called Bash Build system. Basically it got me a file which didn't have /usr/local/bin, this build syntax now returns proper command -v output:
{
"cmd" : ["bash", "$file"],
"selector" : "source.shell",
"osx": {
"path" : "$PATH:/usr/local/bin"
}
}
Need to do install on centos 6 logrotate 3.8.7 out of sources, via chef.
Using simple execute. But also need to check for existing installation. How can I do that thing, if I can't parse logrotate --version output.
logrotate --version | tr -cd [:digit:]
&
logrotate --version | tr -d "logrotate"
and awk - no use..
Even if I don't parse output, chef can't compare it with my variable..
My recipe is:
ver = `logrotate --version`
if ver.eql? "logrotate 3.8.7"
puts "nothing to do"
else
bash "logrotate-source-install" do
user "root"
group "root"
cwd "/tmp"
code <<-EOH
cd /tmp
yum -y install gettext popt-devel
wget https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.8.7.tar.gz
tar xf logrotate-3.8.7.tar.gz
cd logrotate-3.8.7
gmake
gmake install
EOH
end
end
Thx in advance.
Upd.
actual_ver = `logrotate --version 2>&1 | awk '{print $2}'`
ver = "3.8.7"
if actual_ver == ver
puts "nothing to do"
else
bash "logrotate-source-install" do ...
Parsing done, but chef can't recognize output..
You could use attribute only_if to guard this resource for idempotence.
Also, good idea would be to pull version to node attribute like:
default['logrotate']['version'] = '3.8.7'
and then use it in recepie:
version = default['logrotate']['version']
bash "logrotate-source-install" do
user "root"
group "root"
cwd "/tmp"
code <<-EOH
yum -y install gettext popt-devel
wget https://fedorahosted.org/releases/l/o/logrotate/logrotate-#{version}.tar.gz
tar xf logrotate-#{version}.tar.gz
cd logrotate-#{version}
gmake
gmake install
EOH
not_if "[ ${version} = \"$(logrotate --version 2>&1 | awk '{print $2}')\" ]"
end
Better version of this:
bash "logrotate-source-install" do
user "root"
group "root"
cwd "/tmp"
code <<-EOH
cd /tmp
yum -y install gettext popt-devel
wget https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.8.7.tar.gz
tar xf logrotate-3.8.7.tar.gz
cd logrotate-3.8.7
gmake
gmake install
EOH
only_if do
version = shell_out('logrotate --version')
version.error? || version.stdout.split.last != '3.8.7'
end
end
This uses the only_if guard clause to control if the resource converges or not, and uses the shell_out helper instead of Ruby's shell execute syntax. This will be more widely portable, automatically splits stdout and stderr, and will correctly run the install if the command fails. Also doesn't depend on awk.
String parsing via ruby do the thing:
actual_ver = `logrotate --version 2>&1 | awk '{print $2}'`
ver = "387"
if actual_ver.delete('^0-9') == ver
puts "nothing to do"
else
bash "logrotate-source-install" do
user "root"
group "root"
cwd "/tmp"
code <<-EOH
cd /tmp
yum -y install gettext popt-devel
wget https://fedorahosted.org/releases/l/o/logrotate/logrotate-3.8.7.tar.gz
tar xf logrotate-3.8.7.tar.gz
cd logrotate-3.8.7
gmake
gmake install
EOH
end
end
According to the Homebrew installation instructions, the following command can be used to install:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
This works, but it needs user input two times; to confirm the install and in a sudo prompt invoked by the script:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
Homebrew doesn't have arguments for unattended installations, so the only option I can think of is to programatically input the expected data. I tried using expect, but I can't quite get the syntax right:
$ expect -c 'spawn ruby -e \"\$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";expect "RETURN";send "\n"'
ruby: invalid option -f (-h will show valid options) (RuntimeError)
send: spawn id exp7 not open
while executing
"send "\n""
What am I doing wrong?
Unattended installation is now officially supported
https://docs.brew.sh/Installation#unattended-installation
If you want to create a setup script which installs homebrew silently then just pipe a blank echo to the homebrew's installer. Then redirect the results to /dev/null as #charles-duffy suggested.
#!/usr/bin/env bash
# install.sh
URL_BREW='https://raw.githubusercontent.com/Homebrew/install/master/install'
echo -n '- Installing brew ... '
echo | /usr/bin/ruby -e "$(curl -fsSL $URL_BREW)" > /dev/null
if [ $? -eq 0 ]; then echo 'OK'; else echo 'NG'; fi
$ ./install.sh
$ shopt -q login_shell && echo 'Login shell' || echo 'Not login shell'
Login shell
$ type rvm | head -n 1
rvm is a function
-bash: type: write error: Broken pipe
However:
$ rvm --default use 1.9.2
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
I removed ~/.rvm/ and tried installing again using curl -L https://get.rvm.io | bash -s stable --auto but that doesn't help.
It's a remote Ubuntu 13.04, that I have ssh'd into, authenticating with keys. Any advice?
I was sourcing the ~/.rvm/bin/rvm script twice. In the process of uninstalling and reinstalling, it once happened to not modify ~/.bash_profile. I then did this manually. A second uninstall/re-install dance then produced a ~/.bash_profile of:
source ~/.bashrc
# (lines added by me)
if [ -f /ubuntu/.rvm/bin/rvm ]; then
source '/ubuntu/.rvm/bin/rvm' > /dev/null
fi
# (lines added by RVM installer using: curl -L https://get.rvm.io | bash -s stable --auto-dotfiles)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*