I need to pass additional args along with rdebug-ide with bundle exec, something like this.
$bundle exec rdebug-ide <ruby program>.rb <ruby program argument>
$bundle exec rdebug-ide myprog.rb --myprog-initialize-args
rdebug-ide returns invalid option
--myprog-initialize-args
Related
export PS1="\e[48;5;88m\e[38;5;15m\e[K\e[1m\t \e[38;5;82m\u\e[38;5;15m#\e[38;5;82m\h\e[38;5;15m on: \W [\e[38;5;82m\$\e[38;5;15m]\e[0m\n"
With this variable set in .bashrc, exerytime I type exec bundle rake db:migrate.
I don't know what is wrong with the colors commands.
I use GNOME Terminal 3.18.3.
Your command exec bundle... should be bundle exec.... Running the exec command replaces your shell process with the proceeding command.
I have written a shell script where i wrote one rvm-shell command. The issue is any line after this command will not get executed. The script is as follows:
#!/bin/bash
set x
rvm-shell ruby-1.9.3-p448#global //after this line not anything get executed
echo $? //not get executed
clear //not get executed
rails s //not get executed which i want to run
rvm-shell ruby-1.9.3-p448#global
without any parameters is equivalent to running
rvm ruby-1.9.3-p448#global do bash
which will enter shell session and wait for your input.
what you need is:
rvm use ruby-1.9.3-p448#global
or:
source "$( rvm ruby-1.9.3-p448#global do rvm env --path )"
debugging source:
env_file="$( rvm ruby-1.9.3-p448#global do rvm env --path )"
echo "env_file:$env_file:"
source "$env_file"
or use this script:
#!/usr/bin/env rvm-shell ruby-1.9.3-p448#global
rails s
When I invoke commands using bundle exec it takes the parameters I pass in. An example for this would be:
bundle exec my_command run --verbose
In this case --verbose is used as a bundler argument where as it should be used for my_command. I know the following way would work:
bundle exec 'my_command run --verbose'
Is it possible to avoid the quotes? The command I use has already a lot of quotes. I expected something like this would work but it didn't:
bundle exec -- my_command run --verbose
I don't see much documentation about this for bundler. Any ideas would be greatly appreciated.
This looks like what is a common problem when passing one command to another in the shell, and it looks like you're close to what I'd use. Instead of using:
bundle exec my_command run --verbose
Or:
bundle exec -- my_command run --verbose
Try:
bundle exec my_command -- run --verbose
Using bundle exec -- breaks the command-chain for bundle exec. exec is a sub-command for bundle and my_command is a parameter for exec. The parameters for my_command, well, neither bundle or exec needs to know about them so the -- goes where you want to break that chain of parameters to bundle.
Inspecting from source of bundler, it is default behavior to pass all the parameters after bundle exec to Kernel.exec, so the --verbose parameters will be passed to your command, not bundle.
bundle exec my_command run --verbose
will run the following under the context of bundle
Kernel.exec('my_command', 'run', '--verbose')
and
bundle exec -- my_command run --verbose
results in an error because no command/script is named --.
Check the test case here:
#!/usr/bin/env ruby
# coding: utf-8
# file: test.rb
p ARGV
test:
$ bundle exec ruby test.rb --verbose --arg1
["--verbose", "--arg1"]
What is the best way to launch ruby script under another user via su command and from another script?
I have a bash script with the following command for launching unicorn:
sudo -u unicornuser sh -l -c "bundle exec unicorn_rails -E production -D"
This script is an init.d script and it being execute when system starts and manually also.
The problem is the default ruby on system is 1.8, other rubyes (1.9) is working under RVM. I need to modify above script that it can execute ruby with RVM (non system wide)
Now I've migrated for this notation:
su -l -c "rvm use ruby-1.9.3-p125 && bundle exec unicorn_rails -E production -D" unicornuser
this worked for me, but I guess there must be a better way to do this.
You should use wrappers:
rvm wrapper ruby-1.9.3-p125 ext_1.9.3 bundle
This will create $rvm_path/bin/ext_1.9.3_bundle, so now you can use:
/full/path/to/rvm/bin/ext_1.9.3_bundle exec unicorn_rails -E production -D
replace /full/path/to/rvm with output from echo $rvm_path
I'm trying to start unicorn_rails in a ruby script, and after executing many commands in the script, when the script gets to the following line
%x[bash -ic "bash <(. ~/.bashrc); cd /home/www-data/rails_app; bundle exec unicorn_rails -p 8000 -E production -c /home/www-data/rails_app/config/unicorn.rb -D"]
the script stops, generating the following output
[1]+ Stopped ./setup_rails.rb
and returns to the Linux prompt. If I type "fg", the script finishes running, the line where the script had stopped gets executed and unicorn gets started as a daemon.
If I run the line in a separate script, the script completes without stopping.
UPDATE_1 -
I source .bashrc because earlier in the script I install rvm and to get it to run with the correct environment I have the following:
%x[echo "[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\"" >> .bashrc]
%x[bash -ic "bash <(. ~/.bashrc); rvm install ruby-1.9.2-p290; rvm 1.9.2-p290 --default;"]
So if I want to run correct version of rvm, ruby and bundle I need to source .bashrc
end UPDATE_1
Does anyone have any idea what could cause a ruby script to halt as if control-Z was pressed?
Not sure why it's stopping, but my general rule of thumb is to never source my .bashrc in a script -- that might be the source of your problem right there, but I can't be sure without seeing what's in it. You should be able to change your script to something like:
$ vi setup_rails.sh
#!/usr/bin/bash
# EDIT from comments below
# expanding from a one liner to a better script...
$RVM_PATH=$HOME/.rvm/scripts
# install 1.9.2-p290 unless it's installed
$RVM_PATH/rvm info 1.9.2-p290 2&>1 >/dev/null || $RVM_SH install 1.9.2-p290
# run startup command inside rvm shell
$RVM_PATH/rvm-shell 1.9.2-p290 -c "cd /home/www-data/rails_app && bundle exec unicorn_rails -p 8000 -E production -c /home/www-data/rails_app/config/unicorn.rb -D"
This should give you the same result.