Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Prax does not use app gemsets #77

Closed
kwstannard opened this issue Mar 10, 2014 · 28 comments
Closed

Prax does not use app gemsets #77

kwstannard opened this issue Mar 10, 2014 · 28 comments

Comments

@kwstannard
Copy link

It appears to use the global gemset even if you have an app specific gemset.

Steps to reproduce.

  • set up new app and gemset
rails new testapp
cd testapp
prax link
rvm  use ruby@testapp --create --ruby-version
bundle install
  • remove rake from your global gemset
rvm gemset use global
gem uninstall rake
rvm gemset use testapp
  • go to http://sub.testapp.dev and you should get an error
  • open up .prax/_logs/testapp.log
  • you should see something about not having rake in the sources and you can see that it was checking in the global gemset directory, when it should be using the gemset associated with the app
@kwstannard
Copy link
Author

pull request: #78

@ysbaddaden
Copy link
Owner

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 :)

@kwstannard
Copy link
Author

Thanks, I will give that a shot this evening.

@kwstannard
Copy link
Author

If I get it working I could add something to the readme.

@kwstannard
Copy link
Author

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)

@kwstannard
Copy link
Author

it should be using a gemset called pricer.

@kwstannard
Copy link
Author

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

@ysbaddaden
Copy link
Owner

~/.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).

@ysbaddaden ysbaddaden reopened this Mar 12, 2014
@kwstannard
Copy link
Author

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

@ysbaddaden
Copy link
Owner

Nice! But you must set it up for every projects, right? That's cumbersome :(

@kwstannard
Copy link
Author

Yeah, maybe prax link could do something like this:

FileUtils.copy('/prax_path/premade_praxrc', '/app_path/.praxrc') unless File.exists?('/app_path/.praxrc')

@MDCore
Copy link

MDCore commented May 15, 2014

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 :)

@kwstannard
Copy link
Author

@MDCore glad I could help someone. I have rvm_path set automagically somehow.

@helmerj
Copy link

helmerj commented Jul 18, 2014

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...

@MDCore
Copy link

MDCore commented Jul 18, 2014

@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!

@helmerj
Copy link

helmerj commented Jul 18, 2014

It still wont work :-(

Here is what I do (as a regular user):

  1. Unistall old prax stuff to start from scratch
  2. sudo git clone git://github.com/ysbaddaden/prax.git /opt/prax
  3. cd /opt/prax
  4. ./bin/prax install
  5. I copied the kindly provided by @MDCore content for the .praxconfig into ~/.praxconfig
  6. Using the unstable branch the permissions for ~/.prax are correct. In master they belonged to root.
  7. Execute prax link in my rails project's directory resulting in the correct link in ~/.prax

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. :-(

@MDCore
Copy link

MDCore commented Jul 18, 2014

@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.

@helmerj
Copy link

helmerj commented Jul 18, 2014

@MDCore I am running nginx on port 80 actually. stopping nginx fixed it! Coolio! Thanks for your help! :-)

@terlar
Copy link

terlar commented Jul 18, 2014

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

@helmerj
Copy link

helmerj commented Jul 30, 2014

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:

  1. No _socket or _log directory created in .prax
  2. no loading of ~/.praxconfig (tested with echo statements in the file)

How can I make sure the service is even running?

@ysbaddaden
Copy link
Owner

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).

@helmerj
Copy link

helmerj commented Jul 31, 2014

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?

@ysbaddaden
Copy link
Owner

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.

@mattbeedle
Copy link

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

@ysbaddaden
Copy link
Owner

As stated in #91 maybe all that's required is to call cd $PWD instead of reimplementing RVM's logic?

@zmilojko
Copy link

zmilojko commented Oct 5, 2014

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...

@ysbaddaden
Copy link
Owner

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.

@ysbaddaden
Copy link
Owner

I'm closing the issue. Prax + RVM looks like working. I also created a [[Ruby Version Managers]] page on the Wiki.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants