RVM installation: `/usr/local/rvm': Permission denied - ruby

demas#demas:~$ sudo rm -rf /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm
demas#demas:~$ curl -L https://get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 218 0 --:--:-- --:--:-- --:--:-- 308
100 13145 100 13145 0 0 12150 0 0:00:01 0:00:01 --:--:-- 12150
mkdir: cannot create directory `/usr/local/rvm': Permission denied
How can I fix it ?

As a quick variant of eliminating this problem you can create rvm directory and allow everyone to write to it:
sudo mkdir /usr/local/rvm; sudo chmod a+xwr /usr/local/rvm

you need to clean shell environment variables before start new installation, th easiest way is to logout and login again.

I added the sudo on the right side of the '|' before the bash` and it seems to work:
curl -sSL https://get.rvm.io | sudo bash -s -- --version latest**
Result: Downloading https://github.com/wayneeseguin/rvm/archive/1.26.10.tar.gz
Downloading

Related

installing docker-compose using standard procedure gives "permission denied"

I have done this many times but this is new.
Just following the docker-compose install from docker.com
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 633 100 633 0 0 2082 0 --:--:-- --:--:-- --:--:-- 2075
100 12.1M 100 12.1M 0 0 5940k 0 0:00:02 0:00:02 --:--:-- 10.8M
sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
-bash: /usr/local/bin/docker-compose: Permission denied
What is going wrong here ? It used to work before.

Expect script to install Vagrant - terminating for no apparent reason

I am running a simple expect script that uses curl to pull the vagrant dmg, attaches it, installs it and proves password and then detaches.
Individually all the commands execute at the command line and the install works.
However when executing inside of the script it terminates after the curl completes.
#!/usr/bin/expect -f
set timeout 60
exec curl -O https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.dmg
exec hdiutil attach vagrant_2.2.2_x86_64.dmg
spawn sudo installer -package /Volumes/Vagrant/vagrant.pkg -target /
expect "*?assword" { send “password” }
spawn hdiutil unmount /Volumes/Vagrant
The output I get is (concatenated):
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1 31.2M 1 563k 0 0 2218k 0 0:00:14 --:--:-- 0:00:01 8873k
97 31.2M 97 30.5M 0 0 9628k 0 0:00:03 0:00:03 --:--:-- 9627k
100 31.2M 100 31.2M 0 0 9668k 0 0:00:03 0:00:03 --:--:-- 9667k
while executing
"exec curl -O https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.dmg"
(file "./vag" line 9)
At which time the script terminates.
Tcl's exec would fail if the executed command outputs anything to stderr.
curl outputs the download progress info to stderr .
So you need to ask exec to ignore the output to stderr: exec -ignorestderr curl ...

Install script curl'ed from github:

I have the following script hosted on Github:
https://rawgit.com/oresoftware/quicklock/master/install.sh
the contents of that file are:
#!/usr/bin/env bash
set -e;
cd "$HOME"
mkdir -p "$HOME/.quicklock/locks"
curl https://rawgit.com/oresoftware/quicklock/master/install.sh > "$HOME/.quicklock/ql.sh"
echo "To complete installation of 'quicklock' add the following line to your .bash_profile file:";
echo ". \"$HOME/.quicklock/ql.sh\"";
I download and run this script with:
curl -o- https://rawgit.com/oresoftware/quicklock/master/install.sh | bash
but I get this error:
bash: line 1: Moved: command not found
That error is killing me, I cannot figure out what is causing it. I tried curl with both the -o- option and without.
The url for raw git has changed, the error itsel is from curl.
Change rawgit.com to raw.githubusercontent.com.
Another option is to add -L to have curl follow the redirect link.
I figured this out by changing bash to bash -x. Here is the output:
curl -o- https://rawgit.com/oresoftware/quicklock/master/install.sh | bash -x
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 107 100 107 0 0 400 0 --:--:-- --:--:-- --:--:-- 402
+(:1): Moved Permanently. Redirecting to https://raw.githubusercontent.com/oresoftware/quicklock/master/install.sh
bash: line 1: Moved: command not found
#xxfelixxx is pretty much right
This was sort of nightmare, but there appears to be a redirect even when using raw.githubusercontent.com
the only thing that worked with curl was to use:
curl -o- https://raw.githubusercontent.com/oresoftware/quicklock/master/install.sh | bash
For the scripts that require arguments, you can do _ for the script placeholder and then the arguments. For exampe: example.sh that expects --help
curl -L https://raw.githubusercontent.com/<USER>/<NAME>/<BRANCH>/example.sh | bash -s _ --help

RVM failed writing to body [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am trying to install RVM on my Mac running the latest OS.
I first tried
$ \curl -L https://get.rvm.io | bash -s stable
Cannot open for reading: "stable"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 181 0 0:00:01 0:00:01 --:--:-- 181
100 15779 100 15779 0 0 11505 0 0:00:01 0:00:01 --:--:-- 98618
(23) Failed writing body
I then tried dropping the stable
$ \curl -L https://get.rvm.io | bash -s
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 24 2013 18:58:47)
Argument missing after: "-s"
More info with: "vim -h"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 148 0 0:00:01 0:00:01 --:--:-- 148
100 15779 100 15779 0 0 7706 0 0:00:02 0:00:02 --:--:-- 30698
(23) Failed writing body
I have also tried the following
$ \curl -L https://get.rvm.io | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0Vim: Warning: Input is not from a terminal
100 184 100 184 0 0 111 0 0:00:01 0:00:01 --:--:-- 111
100 15779 100 15779 0 0 8689 0 0:00:01 0:00:01 --:--:-- 8300k
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
How about \curl -L https://get.rvm.io | bash?
The installation page for RVM is essential reading.

Ruby manages to fail opening a 644 file as read-only

$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
This is the important line on the script (/etc/munin/plugins/nginx_status_codes.rb:31):
File.open("/var/log/nginx/access.log", File::RDONLY).readlines.each do |line|
My access log has global read permissions:
$ ls -lha /var/log/nginx/access.log
-rw-r--r-- 1 www-data adm 49M May 1 15:56 /var/log/nginx/access.log
The script works if I run from the terminal as a regular user...
$ /etc/munin/plugins/nginx_status_codes > /dev/null && echo $?
0
...but it fails if ran by Munin (which runs as root):
2012/05/01-15:54:05 [3988] /etc/munin/plugins/nginx_status_codes:31:in `initialize': Permission denied - /var/log/nginx/access.log (Errno::EACCES)
2012/05/01-15:54:05 [3988] from /etc/munin/plugins/nginx_status_codes:31:in `open'
2012/05/01-15:54:05 [3988] from /etc/munin/plugins/nginx_status_codes:31
It also fails if I set the file permissions to 777 or whatever. I'm thinking Ruby is just being stupid and reporting the wrong exception (Errno:EACCES) and masquerading the real issue. But what would it be?
UPDATE: Tried to "fix" it by having the script owned by root:root and even with sid/gid bits set it manages to fail with permission denied.
Nevermind. The problem was that logrotation was in place and it changed the log file permissions every now and then:
$ cat /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}

Resources