Closed kwstannard closed 10 years ago
pull request: https://github.com/ysbaddaden/prax/pull/78
Could you switch to the unstable
branch, configure RVM in ~/.praxconfig (just like you configured it in your ~/.bashrc)? It should work without requiring version-manager-specific code to be maintained in Prax :)
Thanks, I will give that a shot this evening.
If I get it working I could add something to the readme.
I changed to unstable and this is what I have in my .praxconfig and it still isn't working.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
Here is the log.
/home/kelly/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/gems/bundler-1.6.0.rc2/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-10.1.1 in any of the sources (Bundler::GemNotFound)
it should be using a gemset called pricer.
This also doesn't work for the praxconfig. It seems to be because the present working directory at the point of it running is the home directory instead of the app directory so it isn't going to load the rvm files. Going to look into it further later.
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`@`cat .ruby-gemset`
fi
~/.praxconfig
is sourced when Prax itself starts (so you may start it outside of a terminal and still have it use your default ruby). It's also sourced when starting Racker from a clean environment, in an attempt to let version managers do their job.
That being said there is #73 about the cleanup of environment variables; maybe some gems and version managers need more environment variables than the very few I let slip by (ie. almost none).
Great, I will probably take a second stab at this too.
Just in case you didn't have this, here is a powrc file that I got working on my mac partition today. It is a bit complex since it has backwards compatibility.
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
else
if [ -f ".ruby-version" ]; then
if [ -f ".ruby-gemset" ]; then
rvm use `cat .ruby-version`@`cat .ruby-gemset`
else
rvm use `cat .ruby-version`
fi
fi
fi
fi
Nice! But you must set it up for every projects, right? That's cumbersome :(
Yeah, maybe prax link
could do something like this:
FileUtils.copy('/prax_path/premade_praxrc', '/app_path/.praxrc') unless File.exists?('/app_path/.praxrc')
I'm on Ubuntu 13.10. I used the .praxconfig that @kwstannard provided but it didn't work. I had to add rvm_path="$HOME/.rvm/"
at the top and now my apps load. Thank you, aside from that addition it was 99.9% of what I needed :)
@MDCore glad I could help someone. I have rvm_path set automagically somehow.
Could some one write briefly how to set this up, which branch and what .praxconfig lines? I have tried every branch with all sorts of different configurations and it still does not work. According to the log files, my rvm ruby binary is not the first in the $PATH variable. How would I accomplish that? I modified the $PATH definition in .praxconfig but that was ignored...
@helmerj
I'm on Ubuntu 13.10. I've checked out prax to /opt/prax/
on the unstable
branch.
This is my .praxconfig
echo "----"
echo "Hi! ~/.praxconfig here :)"
rvm_path="$HOME/.rvm/"
echo $rvm_path
echo $PWD
echo $HOME
echo "----"
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
else
if [ -f ".ruby-version" ]; then
if [ -f ".ruby-gemset" ]; then
rvm use `cat .ruby-version`@`cat .ruby-gemset`
else
rvm use `cat .ruby-version`
fi
fi
fi
fi
The important line for me was rvm_path="$HOME/.rvm/"
. The rest of the lines between (and including) the ----
is debug code that I just left in. Hope that helps!
It still wont work :-(
Here is what I do (as a regular user):
When I then restart my browser and go to http://myapp.dev (myapp replaced the correct name of my link in ~/prax) I get a DNS error and chrome cannot connect to myapp.dev. I have tried to restart the prax service and stopped the background job using prax stop && prax start which outputs the echo lines from ~/.praxconfig. There is no _log directory created in ~/.prax so I am afraid the service is actually not working at all!
Clueless on this one. :-(
@helmerj Are you perhaps running apache? I have to sudo service apache2 stop ; sudo service prax start
, because apache is seems to get port 80 first.
@MDCore I am running nginx on port 80 actually. stopping nginx fixed it! Coolio! Thanks for your help! :-)
If you don't want to stop nginx you could still use nginx as a proxy to prax, using a config like this: https://github.com/ysbaddaden/prax/wiki/Alternate-setup#nginx
Ever since the merge of unstable into master (release of version 0.1.0) the ~/.praxconfig file is ignored and my rvm setup does not work anymore. :-(
After a fresh install:
How can I make sure the service is even running?
Please try to run Prax with PRAX_DEBUG=1 prax start --foreground
, that should help debug what's happening. ~/.praxconfig
is still always loaded, and the _sockets
and _logs
folders are lazily created (when required).
Coolio! Ever since I started the service with the debug var and foreground flag it works again. Even without them flags. Before I had re-installed rebooted several times and it didn't. Don't know why but on't care as well. It works, that makes me happy. Thanks a lot! :-)
UPDATE:
IF I start prax outside my project's directory the command ignores my ~/.praxconfig file and I cannot start the app using myapp.dev
If I start prax inside the project's directory, the ~/.praxconfig file is read and the app can be used under myapp.dev
Don't think that is desired behavior is it?
Then nothing is fixed. This is working when run from project directory because prax will be run using RVM and your project's ruby version, which won't be the case outside (maybe it's the system ruby).
Please note that prax start
is a shell script (bin/prax
and libexec/prax-start
) that is sourcing ~/.praxconfig
, there is no ruby involved at this point, and thus your RVM config in ~/.praxconfig
isn't working as expected.
Please run with the PRAX_DEBUG flag and then debug prax.log
and myapp.log
in ~/.prax/_logs
to understand what's not working.
The solution posted by @MDCore works for me. I noticed though that when I run PRAX_DEBUG=1 prax start --foreground
in the project directory I see a warning about the PATH
:
Warning! PATH is not properly set up, '/home/matt/.rvm/gems/ruby-2.1.2/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.2'.
This warning does not appear if I run the same command from any other folder
As stated in #91 maybe all that's required is to call cd $PWD
instead of reimplementing RVM's logic?
So I tried all from #77 and #91, but the only thing that helped me in the end was:
rvm_path="$HOME/.rvm"
source "$rvm_path/scripts/rvm"
cd $PWD
rvm use ruby-2.0.0-p451
It works and I do not want to be spending (wasting?) more time on this, and @ysbaddaden - thanks a lot, Prax is really awesome, in particular for demos, but I am one more problem away from uninstalling RVM completely and just using one Ruby at the time...
I did switch to a single Ruby runtime on a fresh linux install, using my ruby-updates ubuntu ppa and Vagrant boxes for bigger projects (they usually need special software anyway). I'm still using Prax directly for small projects and for port-forwarding to the Vagrant boxes.
I'm closing the issue. Prax + RVM looks like working. I also created a [[Ruby Version Managers]] page on the Wiki.
It appears to use the global gemset even if you have an app specific gemset.
Steps to reproduce.
http://sub.testapp.dev
and you should get an error.prax/_logs/testapp.log