Hot answers tagged

17

Don't dismiss RVM's value You can use the repository version of Ruby but I would recommend going another way and using RVM to manage Ruby. I realize it might seem like it's slowing you down, but the version of Ruby that's deployed via the repositories though usable will often lead to problems down the road. It's generally best to create dedicated versions ...


11

logrotate is used by the system to rotate logs so you have 2 choices. You can either incorporate the rotation of these app logs into the systems rotations or setup your own and either run them manually or from the root user's crontab (Assuming the Rails app is run as root given it's directory is /root/...). System rotation To setup a logrotation within the ...


10

If you are using RVM then it is just a matter of putting a file named .rvmrc in your project directory with the following content: rvm use ruby 1.9.x@gemset For your second project it is the same, just change the rvm invocation.


10

There should be no difference. Pipe the output through cat -v which will escape non-printable characters. Perhaps you have some special locale settings, which modifies what -print0 does. At least with my en_US.UTF-8 settings there is no difference. Perhaps add the output of locale to your question. Possibly your test with ruby causes ruby to interpret the \...


9

That the remote declined to receive the data is only a side effect of the real problem -- git thinks that it was denied because one of the hooks on the remote end failed with an exit status >0 (you can see what it was in the Ruby traceback). It seems that one of the hooks tries to use rake, and can't find it. This is not a problem with your specific repo, ...


8

In gVim you can select the font, vim depends on the font the terminal provides. And it's the same for colour support. Gvim has full support, vim depends on the terminal. Gvim additionally has menus and a toolbar, which vim lacks. One big advantage of vim is that, since it's a terminal application, you have a full fledged terminal at your fingertips. gVim ...


8

You need to run the shell as the user, not the curl or the which command. There are several ways this can be done, including: sudo -u user bash -c 'curl -L https://get.rvm.io | bash' and curl -L https://get.rvm.io | sudo -u user bash If you want to do it interactively, you can use sudo's -s option to override the fact that they don't have a valid shell. ...


7

According to the official docs it sounds like you just need to prefix your scripts like this: #!/usr/bin/env ruby And then do one of the following things to tell rbenv which version of Ruby to use: excerpt: https://github.com/sstephenson/rbenv Choosing the Ruby Version When you execute a shim, rbenv determines which Ruby version to use by reading ...


6

You could try sourcing the new environment files. Looking above, I guess, # SHELL NEEDS TO BE REFRESHED HERE source /etc/profile.d/rbenv.sh and/or source ${HOME}/.rbenv plus any other files that have been created, that you need including in the current shell.


6

You may wish to consider using a ruby package manager like rvm or rbenv You can install different rubies and switch between them easily. You might also want to consider trying 2.0+ Sample output from rvm: 21:59:48 durrantm Castle2012 /home/durrantm $ rvm list rvm rubies ruby-1.8.7-p374 [ x86_64 ] ruby-1.9.3-p125 [ x86_64 ] ruby-1.9.3-p194 [ ...


6

Aliases can be of use to you. You can create alias for each specific directory and the command you need to run. So for the two example you have given it would be: alias ticketapp='cd /proj/tickecting_app && rvm use ruby 1.9.x@gemset' alias feedapp='cd /proj/rss_feed_app && rvm use ruby 2.1.x@gemset' So next time you only need to give the ...


5

From the latest version of the kill(2) manpage: For a process to have permission to send a signal to a process designated by pid, the user must be the super-user, or the real or saved user ID of the receiving process must match the real or effective user ID of the sending process. A single exception is the signal SIGCONT, which may always be ...


5

The short answer is that you can't. The idea behind using #!/usr/bin/env ruby instead of simply #!/usr/bin/ruby is to use whatever ruby binary is first in the user's path. Then your script doesn't depend on ruby being in the same place on every system; after all, a 'normal' ruby location might be /usr/bin/ruby, /usr/local/bin/ruby, /opt/ruby-1.8.7/bin/ruby, ...


5

You're having problems with quoting because you're calling popen with a commandline, which is passed to the shell. Ruby's string parser is either eating the double quotes or eating the backslash. You can either call popen with an array of strings, which will bypass the shell, or you can write emacs foo\\ bar which will escape the backslash that you want ...


5

I'm not sure if that answers your question, but the pwdx could give you the current working directory of any process. Like this: pwdx <PID> You could also do what Ulrich Schwarz said and run ls -l /proc/PID/cwd


5

I'd recommend that you use rvm to manage Ruby versioning. First install rvm: curl -L get.rvm.io | bash -s stable --autolibs=enabled . ~/.rvm/scripts/rvm rvm requirements You'll probably want to source that on shell startup as well, so add it to your ~/.bashrc: cat >> ~/.bashrc << 'EOF' [[ -r ~/.rvm/scripts/rvm ]] && . ~/.rvm/scripts/...


5

It's because creating a giant string and passing it as an argument isn't what "here documents" do. They create a stream, which can be connected to some job's input. Concretely, cat <<! foo ! is not equivalent to cat foo . Speaking of cat, it can help us out here. Warning: non- useless use of cat follows! echo $(cat <<! foo ! ) See, we can ...


5

Replace: if [ -z `cat rvm_check.txt | grep not` ] With: if ! grep -q not rvm_check.txt The reason to use test in an if statement is because it sets an exit code that the shell uses to decide to go to the then or else clause. grep also sets an exit code. Consequently there is no need for test, [, here. grep sets the exit code to success (0), if it ...


5

Definitely, the bundle-gem online manual was created from the bundle-gem.ronn file. And ronn is a format (and program) meant to be formatted as a man page. First let's get the files (for bundler-gem and ronn): git clone https://github.com/bundler/bundler.git gem install ronn # this actually depends on mustache, rdiscount and hpricot And create the man ...


4

Your Tiny Core Linux install probably has a bare-minimum shell installed. This is probably busybox. You can verify this by checking if /bin/sh is symlinked to something else: ls -l /bin/sh lrwxrwxrwx 1 root root 7 Dec 15 20:52 /bin/sh -> busybox Since Tiny Core Linux loads the bare-minimum OS into RAM, this is desirable. However, ...


4

The closest thing I can see is Capistrano. With fabric: from fabric.api import run def uptime(): run('uptime') then: fab -H localhost uptime With Capistrano: task :uptime, :hosts => "localhost" do run "uptime" end then: cap uptime


4

You could also try just installing the ruby-dev package: sudo apt-get install ruby-dev


3

Can't find the 'libpq-fe.h header If you haven't done it already, install and initialize apt-file. This tool tells you what package contains a file with the given name. sudo apt-get install apt-file apt-file update Then run apt-file search libpq-fe.h to find out what package contains this file, and install the package in question. (It's libpq-dev.) You ...


3

Look for it: find / -name ruby 2> /dev/null If you get a positive location, make sure that the directory is in your $PATH. If you don't get any output, your Ruby installation didn't go as planned.


3

Maybe you will find it as the target of /proc/(pid)/cwd. It looks like it, but I'm not very at home in /proc.


3

You cannot. However, you can trick pacman into thinking you have (there are two ways to do this). Simply pass the --dbonly option: pacman -S --dbonly ruby This will commit the transaction to the database (make a record of the install), but not actually download or install any packages. If you want, you could also pass --asdeps to mark it as a dependency. ...


3

With perl and look-around advanced regex : perl -lpe 's/((?<!\{).*?\.to.*)}\s*$/$1/' file and with awk : awk '!/{/ && /\.to.*}/{sub(/\}/, "", $NF)}1' file


3

In sed, you must escape the parentheses and |. /\.to\( \|_not \)<\=/ s/<\=/be <\=/ Alternatively, in your example you could use ? (also escaped): /\.to\(_not\)\? <\=/ s/<\=/be <\=/


3

Printing to a console (especially a remote console) is a fairly expensive operation if done in a tight loop that's executed frequently. Most Ruby I/O is blocking, so it will drastically slow down the execution of the program. You should get a much more reasonable result if you send the output to a file (or /dev/null, if you don't care about it) instead: ...


3

It's because you're echoing all the numbers out to the screen via the puts. These then have to be sent over the SSH connection which extends the amount of time the scripts takes to run. The output is also buffered locally but the effects aren't as noticeable. You can confirm this by dumping all the output to a file instead. Examples local on laptop to ...


Only top voted, non community-wiki answers of a minimum length are eligible