Capistrano isn't applying path environment to second command - path

My Capistrano deployments are hanging on the second command in a composite command.
https://github.com/capistrano/capistrano/blob/5986983915163e6681f2546bf6fad599d58cd024/lib/capistrano/dsl.rb#L59
At the point that SSHKit tries to run the following command:
cd /home/lawfm/deployments/staging/repo && git rev-parse
I get a
bash: git: command not found error.
I believe the issue is documented here:
https://github.com/capistrano/capistrano/issues/675
My deploy was working in 3.0.1, but an upgrade to 3.1 introduced the error. At first, I read that pty was now on by default, so I set:
set :pty, false
Unfortunately, it seems neither .bash_profile nor .profile are being loaded, so any attempt to augment the PATH there have been fruitless.
I can't seem to figure out a way to set the path or even map the git command directly since it's the second command.

I can't figure out a way to fix the path not being applied to the second command, but I did place the PATH definition in my .bashrc file instead of .bash_profile and it now works.

Related

How can I add git to the ruby command line?

I am looking to access git commands from the Ruby command line in Windows 10 however when I attempt to run a git command I get a "git is not recognized" error. I can call git commands from the standard command line without any problems. I have updated my paths to include C:\Program Files\Git\cmd\ and C:\Program Files\Git\bin\ however this has not resolved the error. Any other suggestions of how to solve this?
Make sure you've set your PATH to git correctly. By default, git should already be configured to PATH automatically. Go to this link and download the correct version for your system and then install it. Afterwards, open the windows terminal and everything should work.
This may help you out: How to run Ruby and GIT commands in one place on Windows

How do I run 'rails server' inside a shell script?

I'm trying to write a shell script that automatically runs my rails app in a virtual machine.
My script code is this:
#!/bin/sh
PATH='/usr/local/rvm/gems/ruby-2.0.0-p481/bin'
cd /home/lgdelacruz/SampleApp
rails server
But for some reason it doesn't see all the dependencies. this gives me the error
/usr/bin/env: ruby: No such file or directory
I'm positive ruby is installed in the virtual machine. I can run rails server by manually going inside my virtual machine going to my SampleApp folder and running rails server there and everything works fine. But for some reason when I put all that in a shell script. it doesn't work.
You've probably got to initialize RVM in your script first. Try putting this line in:
source "$HOME/.rvm/scripts/rvm"
You might also need to specify a gemset, if you're using something other than the default:
rvm use #mygemset
See the RVM scripting docs for details.
In your shell script, you've reset your path to only include /usr/local/rvm/gems/ruby-2.0.0-p481/bin. ruby is usually installed somewhere like /usr/local/bin
instead you could concatenate that directory onto the end of your existing path.
something like:
export PATH=$PATH:/usr/local/rvm/gems/ruby-2.0.0.p482/bin

How to use rails bundler behind a proxy network?

I am using ubuntu 12.04. I am trying to run
bundle install
behind the proxy network of my institute.I have correctly setup the apt.conf file and all other downloads from terminal are working fine. I added the following to ~/.bashrc
export HTTP_PROXY=http://user:password#proxy_url:port
alias curl="curl -x http://proxy_url:port/ -U user:password"
alias rvm="rvm --proxy http://user:password#proxy_url:port"
And i added the following to my environment file:
http_proxy="http://user:password#proxy_url:port/"
https_proxy="https://user:password#proxy_url:port/"
ftp_proxy="ftp://user:password#proxy_url:port/"
socks_proxy="socks://user:password#proxy_url:port/"
I also added the following to ~/.gemrc:
http-proxy:http://user:password#proxy_url:port
After making all these changes when i run the bundler using with or without sudo on the terminal i get back the source code of some html page.The code of html page is followed by the line:
Net::HTTPProxyAuthenticationRequired:
Please tell me what to do to make rails run behind the proxy.
This isn't a Rails question per-se, it's a Bundler question.
I would try the following on the command line (either should work):
export HTTP_PROXY=http://user:password#proxy_url:port
export http_proxy=http://user:password#proxy_url:port
Potentially your ~/.bashrc file isn't being executed on login/etc.
I would also change the ~/.gemrc file to: http_proxy=http://user:password#proxy_url:port
Check out the source code in Bundler for any extra information you may need.

How to run Ruby and GIT commands in one place on Windows

I have Ruby and GIT installed on my windows box. To run GIT commands I am utilizing the GIT Bash. To run Ruby commands I am using the command line.
I have not been successful running GIT commands from the CMD line nor can I seem to run Ruby commands from inside the GIT Bash. I would love to be able to run commands for both GIT and Ruby from the GIT Bash (ideal) or at the least from the CMD line.
What is the best way to go about this?
I run git commands from the CMD session all the time.
Make sure your PATH environment variable includes the 'cmd' directory from a msysgit distro:
Path=C:\Path\To\Git\1.7.1\cmd
If not, add it in your session:
set PATH=%PATH%;C:\Path\To\Git\1.7.1\cmd
and you are done. Git and Ruby commands in your CMD shell.
The reverse (Ruby commands) is possible in a Git bash, by adding to the PATH a value like /c/path/to/Ruby/186-27/bin
To elaborate on VonC's answer of making Ruby available in Git-Bash.
All you have to do is add the path to your Ruby bin folder in your windows environment variables. It doesn't have to be in the format /c/path/to/ruby, it can be C:\Ruby193\bin.
Step by step for Windows 7:
Start
Search programs and files (default textbox after hitting the Start icon), Search for 'environment'
Select 'edit the system environment variables'
Click 'Environment Variables' (bottom right of the form)
Add to the 'System Variables' 'PATH' the following ';C:\Ruby193\bin' (without the single quotes)
Restart your shell
Make sure to close your git-bash shell and restart it to pick up the new environment variable.
Go to My Computer -> Properties -> Advanced system settings ->
Environment Variables
Add a New System variable. Variable name = RUBY_BIN. Variable
value = C:\Ruby193\bin (path may vary).
Add a New System variable. Variable name = MSYSGIT_BIN. Variable
value = C:\msysgit\bin (path may vary).
Append ;%RUBY_BIN%;%MSYSGIT_BIN% to Path variable, under System variables.
Restart shell.
This will allow you to run ruby, git or sh (Git Bash) commands from Command Prompt, as well as Ruby from Git Bash.
My personal setup uses msysgit and tortoisegit. I've found that using TortoiseGit's Pageant manager for the keys lets me use everything from any command line, including powershell. The only annoyance is I have to have pageant running with the keys added, which seem to clear on every reboot. Fortunately I don't reboot often.
The combined answer for VonC and Rots helped me to achieve the desired results.
However, since I was not familiar with editing environment variables, I must have accidentally overwritten the path for my nodejs files.
As a result my solution included adding the ruby path and the nodejs path to my user variables instead of the system.
I'm using a Windows 7 machine.
while installing ruby installer, select the option "Add ruby executables to your path" . Then all git/ruby commands will run from git bash.

Heroku deployment error

In a windows environment I am getting the following error when trying to deploy to Heroku
C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/base.rb:32:in ': No such file or directory - git
remote (Errno::ENOENT)
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ba
se.rb:32:in shell'
from C:/Ruby/lib/ruby/1.8/fileutils.rb:121:in
chdir'
from C:/Ruby/lib/ruby/1.8/fileutils.rb:121:in
cd'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ba
se.rb:32:inshell'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/commands/ap
p.rb:52:in create'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
48:insend'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
48:in run_internal'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/lib/heroku/command.rb:
20:inrun'
from C:/Ruby/lib/ruby/gems/1.8/gems/heroku-1.9.13/bin/heroku:13
from C:/Ruby/bin/heroku:19:in `load'
from C:/Ruby/bin/heroku:19
Any idea how I can correct this? This is being run from the Ruby Command line (which seems to me like the regular command line)
Ok so I figured out a way to make it work and why it is likely happening.
For some reason I can only run the Ruby commands from the CMD prompt however the GIT commands only seem to work from the GIT Bash. When in the GIT Bash the Ruby commands don't work.
When you run the Heroku commands to create the service it seems to want to run certain GIT commands which don't work from the CMD prompt the way I have it set up.
To get around this for the moment I am adding the Heroku path for GIT as a remote manually and then pushing that manually when needed. An extra step but everything still works as intended.
If you need help with the work around check out the information in this link: http://www.wiki.devchix.com/index.php?title=Working_around_the_%22heroku_create%22_error
I'd still recommend using Git Bash over the normal windows CMD prompt.. but I know how tedious that can be sometimes.
You can bypass the need to do this however and get your Heroku gem working properly in your windows CMD prompt by adding your msysgit/bin path to your system Path variable.
That'll give your heroku gem access to the git command.
To add heroku as remote use the following:
git remote add heroku git#heroku.com:yourappname.git
Then push your master copy to Heroku:
git push heroku master

Resources