No such file to load bundler error for Rails 3 - ruby

I have a Rails 3 app ready for staging.
I haven't got a VPS host set up yet. As I was planning to have everything on shared host for the first few months.
Problem:
cd myapp
bundle check
result:
The Gemfile's dependencies are satisfied
Passenger error:
Error message:
no such file to load -- bundler
Exception class:
LoadError
Frustrating thing about shared hosts is that I have to add these lines on config.ru:
ENV['GEM_HOME'] = '/home/username/.gems'
ENV['GEM_PATH'] = '$GEM_HOME:/usr/lib/ruby/gems/1.8'
Still no luck. Same no such file to load bundler error appears.
Has anybody got this working? Rails 3, Debian, shared host (dreamhost)?
I could just go ahead and register on Slicehost/Fivebean but before I do, I'd like to know why that error is showing up.
Thanks.

The solution is here http://rvm.beginrescueend.com/integration/passenger/. You need to point your HTTP server to passenger_ruby wrapper instead of bin/ruby.
E.g. for RVM & Apache it should be something like that:
PassengerRuby /Users/username/.rvm/bin/passenger_ruby

Passenger doesn't read environment variables from config.ru until after it has loaded. Without your backtrace I can't be positive, but I suspect everything will work if you just run bundle lock. If you're still having trouble after that, there's a list of troubleshooting information at the bottom of the bundler README that I need to know exactly what's going on.

Rails hosting on shared hosts is already a minefield, but throwing in Rails 3 in all its pre-release goodness including Bundler reinventing the rubygems workflow is a recipe for pulling your hair out.
I host a few Rails sites on Dreamhost, but only the versions they officially support, otherwise it's just not worth the time. You can get a VPS now for almost as cheap as Dreamhost, and you will save hours and hours of your own time.
If you're looking for an easy answer, I'd suggest voting up the following and crossing your fingers:
Rails 3 on dreamhost?

For me, this turned out to be an issue with the passenger_ruby directive that passenger-install-nginx-module spits out at the end of installation. It was missing the gemset name in the path to the ruby.
This works: (the fix)
passenger_ruby /Users/dzello/.rvm/wrappers/ruby-1.9.2-p0#rails3/ruby;
This did not: (what passenger-install-nginx-module spits out)
passenger_ruby /Users/dzello/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
Note the passenger_ruby line does not include the proper gem path - the #rails3 (rails3 is the gemset name) portion is missing, even though it got it right for passenger root.

Found some random blog. It had some lines that went in 'config.ru', that seemed to work for me.
ENV['GEM_HOME'] = '/home/farleyknight/.gems'
ENV['GEM_PATH'] = '$GEM_HOME:/usr/lib/ruby/gems/1.8'
require 'rubygems'
Gem.clear_paths
Maybe it will work for you..

I had this problem with vps plus rvm, rails3, capistrano and nginx.
Passenger was installed by root but the web site was installed by user fox. Nginx (root) was configured to run the app as fox. When logged in as fox, Bundler was installed but running gem list bundler as root showed no gem.
Passenger start would give error bundler was missing. Only cure for this was to install bundler as root AND fox. I'm guessing passenger checks for bundler while not under the user fox as configured in nginx.

Related

Jekyll and Redcarpet (plus dependencies)

Up until a few hours ago, I had my jekyll install working as normal. Having created 26 different posts using my current setup, I'm not expecting something to suddenly not work at all. Ran jekyll build to see the results of a new post I created for my blog. I got an error saying it could not find redcarpet; weird since I have never touched my config or anything since I created it. I ran bundle install no new gems added. For sanity's sake I ran bundle show redcarpet, it could not be found. Okay that's weird. So I run gem install redcarpet v 3.1.0 which was the version I was using pretty much the entire time. I then run bundle install again, checking to see if redcarpet was added...and nope.
I decided to go into my config and switch markdown parser and add kramdown, then run jekyll serve...and now I get that I'm missing kramdown and like redcarpet even if I install via gem install jekyll refuses to acknowledge it's existence.
I tried deleting my gemfile and rebuilding it unfortunately that does nothing. If I run bundle exec jekyll serve it works however redcarpet isn't activated and thus the markdown isn't parsed correctly (And new entries aren't added to the index page).
I'm probably missing something obvious, any direction or advice would be much appreciated.

rake preview generating site without styles

I've set up a vanilla Octopress blog & I am hosting on github pages, but am encountering some issues when using rake preview.
To help troubleshoot, here's a short list of changes I've made since setting up Octopress (that I can recall):
in _config.yml, changed the url to my domain
in _config.yml, changed root to "/"
in _config.yml, specified my github repo under 3rd party settings
added CNAME pointing to my domain in /public/github
added CNAMe pointing to my domain in /source/
made a post using rake new_post
Here's a description of the issues:
http://localhost:4000 yields a 404, however, I am able to see my site at http://localhost:4000/github/index.html
When previewing /github/index.html, most of the stylesheets/JS are returning a 404.
Here's what happens when I run rake generate, followed by rake preview:
Starting to watch source with Jekyll and Compass. Starting Rack on port 4000
Configuration from /Users/[redacted]/Documents/code/octopress/_config.yml
[2013-09-09 10:21:44] INFO WEBrick 1.3.1
[2013-09-09 10:21:44] INFO ruby 1.9.3 (2013-06-27) [x86_64-darwin11.4.2]
[2013-09-09 10:21:44] INFO WEBrick::HTTPServer#start: pid=39870 port=4000
Auto-regenerating enabled: source -> public/github
[2013-09-09 10:21:45] regeneration: 95 files changed
>>> Change detected at 10:21:45 to: screen.scss
identical public/github/stylesheets/screen.css
Dear developers making use of FSSM in your projects,
FSSM is essentially dead at this point. Further development will
be taking place in the new shared guard/listen project. Please
let us know if you need help transitioning! ^_^b
- Travis Tilley
>>> Compass is watching for changes. Press Ctrl-C to Stop.
You need Python 2.x. You should be able to check your Python version at the command prompt with python --version
If you don't have it then if you are on Windows, download and install Python 2.7.6 from http://www.python.org/download/
then add C:\Python27 (or the folder where you installed Python) to your path environment variable.
Did you change the destination setting in _config.yml. Default should be something like this:
root: /
permalink: /blog/:year/:month/:day/:title/
source: source
destination: public

Generating RDOCs for locally installed gems

I am trying to contribute to a gem I recently took interest in - Nesta. The developer has done a great job in creating one of the lightest, thinest CMSs you can find and I want to document it. I have read through the code and commented on a few methods to the best of my knowledge.
However, I seek to test this out locally by calling gem server and seeing the changes on my machine before pushing it online.
Things I have tried:
Manual edit.
Documented the file.
Fired up gem server.
Using the gem tool.
Documented the file.
Ran gem rdoc nesta --rdoc
Restarted gem server
All to no avail. Please help.
Thank you.
You can preview generated html pages without installing a modified version of the gem on your machine. Add this to nesta's Rakefile:
require 'rake/rdoctask'
Rake::RDocTask.new('doc') do |i|
i.rdoc_files = FileList['lib/**/*']
end
and type rake doc. Then view generated html/index.html file.
Are you sure you've installed the version that you've modified, not the original version?
If you've installed the modified version, but have forgotten to install the rdoc, see Can you install documentation for existing gems?

Sinatra cannot find views on Ruby 1.9.2-p0

I'm quite new to Ruby language (up to now I developed in Groovy + Grails) but since I was curious about it I wanted to try Sinatra on Ruby 1.9.2-p0.
I have a trivial website that is contained in /mywebpage and has 2 files:
# blog.rb
get '/' do
'Hello World!'
end
get '/impossible' do
haml :index
end
and
#config.ru
path = File.expand_path "../", __FILE__
$LOAD_PATH << (File.expand_path ".") + "/views"
require 'haml'
require 'sinatra'
require "#{path}/blog"
run Sinatra::Application
then in the same folder I have a /views/ folder that contains index.haml.
I try to run the server with rackup -p8080 but when I try to get /impossible I receive the following error:
Errno::ENOENT at /impossible
No such file or directory - /home/jack/mywebpage/<internal:lib/rubygems/views/index.haml
By searching over internet it seems that this maybe caused by "." not being included in $LOAD_PATH so I tried to add it or add directly views ./views so that actually $LOAD_PATH.inspect gives me correct path: ..., "/home/jack/mywebpage/views"]
But still it doesn't seem to work. Being quite new to the framework and the language I was wondering if I'm doing something wrong. any clues?
Running Sinatra with Ruby 1.9.2 the template directory is no longer implicitly 'views', you need to set it yourself.
set :views, File.dirname(__FILE__) + "/views"
Note that currently Ruby also has Kernel#__dir__() method that is equivalent to File.dirname(__FILE__).
This, and other issues with 1.9, will be have been solved in Sinatra 1.1. You could use this fork: http://github.com/rkh/sinatra/tree/1.1
I ran into a similar problem, and solved it like this. I didn't dig into the problem, but this is what I found and it works. It'll supposedly be fixed in the next version of Sinatra (which they should really get out the door, just to fix these few 1.9.2 bugs).
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
enable :run
get '/' do
"Hello, world!"
end
Edit: It seems there are multiple bugs with Sinatra on 1.9.2. This one will fix Sinatra apps not starting on 1.9.2. I don't use a views directory (I like to keep my apps single-file), so I didn't run into your particular problem. This fix most likely won't help you at all. I probably should have read your problem more closely..
gem install sinatra --pre
I ran into that last week and didn't find a suitable fix on the Sinatra site short of tweaking the sinatra code. I'm using rvm for my development and switched to try sinatra on Ruby 1.8.7 and it works fine again, so that's where I left it.
Oh, since you're new to Ruby, you might not know about rvm, so here's the lowdown. RVM is Mac only and highly recommended for managing your Ruby version and gems. It makes it trivial to have multiple Ruby versions and alternate groups of gems for development and testing. Everything is stored in your ~/.rvm directory so it's easy to blow it all away if you need to.
http://rvm.beginrescueend.com/
I just looked at the Sinatra site again about the problem to see if there was anything new, but it appears they consider the following to be an acceptable fix:
http://github.com/sinatra/sinatra/issues/#issue/50
I'm a bit adverse to having to edit the source of Sinatra as recommended by issue #50, but it's not real hard to do. I'd like to see them put out an update so we'd have an official fix but I haven't seen anything yet:
gem env will tell you the "GEM PATHS". Sinatra's gem will be in one of those. The line mentioned in issue #50 goes into base.rb. On my machine it's something like ...gems/ruby-1.9.2-p0/gems/sinatra-1.0/lib/sinatra/base.rb.
Insert:
/<internal:/, # ruby 1.9.2-p0 hacks
at line 1020.
Save the file and you should be good to go.

How can I get past "http://gems.rubyforge.org/ does not appear to be a repository" error message

Question 828421 asked similar question, but received only one real answer (update rubygems) and that attempt results in the same error.
Ruby version 1.9.1.p243 on Windows. Included Gem, version 1.3.5.
Never installed any gems before; never did any special config for this Ruby.
Ruby itself works, as does irb, and "gem" operates but can't do install (and maybe other ops).
Tried this (from a book):
gem install rspec
Got this:
ERROR: http://gems.rubyforge.org/ does
not appear to be a repository
ERROR: While executing gem ...
(Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: The storage control blocks were destroyed.
(http://gems.rubyforge.org/yaml)
When I go to that URL (without "yaml") using MSIE7, I get a page titled "Gemcutter | awesome gem hosting" and have no problem wandering around that site. So I don't -think- it's a proxy problem (though this is all from inside corporate firewall/proxies/etc).
When I go to that URL -with- "yaml", it goes to "http://production.s3.rubygems.org/yaml" and shows what I assume is an update specification page, starting with this:
--- !ruby/object:Gem::SourceIndex
I didn't destroy any "storage control blocks". So what is preventing gem from installing a gem?
Web search shows MANY people having this same problem over a long span of time, but I have yet to see anyone say "It's because of THIS, so do THIS to fix it." Well, someone suggested updating "gem", but trying that gets same error.
Help please?
Your browser might be using system-wide proxy settings or some sort of automatic configuration. The gem command probably doesn't. I'm behind an university proxy and I can't install/update any gems normally, but can access everything with my browser. To install gems, I normally create a tunnel to my server so I can bypass the proxy server.
This might help you to configure the proxy settings for the gem command: How do I update Ruby Gems from behind a Proxy (ISA-NTLM)
Sample:
sudo gem install nifty-generators -p http://proxy:port
It works well.
If your proxy requires authentication, then use:
gem install --http-proxy http://USERNAME:PASS#HOST:PORT gem_name
This can "at times" mean that for some reason rubygems.org is down currently, and so your local "invisible proxy" is returning you a 404 or what not.
#Tomas Markauskas didn't work for me because i'm not behind a proxy. And I didn't find a solution anywhere, I tried disable my AV and firewall, didn't
This was the solution for me:
gem install rails -r -w -p
Hope this will help people with the same problem.
EDIT: I have Windows 7 64bit.

Resources