Cannot call method 'charAt' of undefined - only on server - ruby-on-rails-3

I have a rails application which is running well in local (OsX, WEBrick).
I've cloned the repo on a server (Ubuntu 10.04, Apache, Passenger), setted up passenger, but now when i try to connect to every page i get
Less::ParseError in Pages#home
Showing /var/www/MYAPP/app/views/layouts/application.html.erb where line #5 raised:
Cannot call method 'charAt' of undefined
(in /usr/lib/ruby/gems/1.8/gems/twitter-bootstrap-rails-2.0.2/vendor/assets/stylesheets/twitter/bootstrap.css.less)
the content of bootstrap.css.less is:
#import "twitter/bootstrap/bootstrap";
line 5 of application.html.erb is:
<%= stylesheet_link_tag "application" %>
ruby 1.8.7 on both machines

solved upgrading to ruby 1.9.3

Upgrading less worked for me on Ubuntu server 10.04
For system wide:
sudo npm -g install less
For user only:
npm install less

I believe this has something to do with the Ruby less gem not compiling it correctly. I had this problem locally on mac as well. Somewhere I saw a suggestion to use the node version of less (1.3) instead of the ruby gem, which you can install with npm install less.
However, most of the gems that hook up bootstrap to rails use the ruby gem version, so it seemed like a no go, esp on heroku etc. After a very frustrating couple of days on this I gave up and switch to the sass version of bootstrap: https://github.com/thomas-mcdonald/bootstrap-sass
It was simpler to integrate with rails, but unfortunate to be off the official version of bootstrap. I later went to integrate bootswatch but this doesn't play well with sass either. So I'm back to the plain old css version of bootswatch for now until a better way to handle this comes out :/

Related

I tried to install Rails 4 gem y my CPanel and didnt work

I have almost finished my first Ruby on Rails application, i have used Ruby 2.1.2 and Rails 4.2.4.. then i want to deploy it, the hosting i took gave me 1month trial but they have installed CPanel 11 (it has rails 2.3.18 by default)
but when i try to install the rails 4.2.4 gem it gives me this:
> Error installing rails: i18n requires Ruby version >= 1.9.3.
My questions are:
Is there a way to update the ruby?
Would i have any trouble if they just update to 1.9.3 when i have used 2.1.2?
this is a screenshot from the gems in the cpanel
Recently I had to upgrade my Ruby version to a higher one and I was in a very similar situation like yours.
I used rvm for this.
Use rvm for listing the ruby version with the following command:
rvm list known
Then upgrade ruby with: rvm install version_of_your_choice
Also, search the internet for tutorials. StackOverflow has all the answers.

Passenger throws Bundler::GemfileError after "gem update --system"

Background
On my local machine, I tried installing the 'bullet' gem via my gemfile, and bundle seemed to go without incident, however upon restarting my app passenger began throwing the error Invalid gemspec for uniform_notifier. It seems someone else had this issue and the suggested resolution on StackOverflow said to update RubyGems by running:
The issue
gem update --system
This produced no error messages upon running, however now none of apps will start. They all give the same vague Passenger error:
PhusionPassenger::UnknownError
There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError)
I removed 'bullet' from my gemfile so it's now back in a state when it was working yesterday, so I don't think there can be an error in my gemfile. Furthermore, all of my other apps are now broken and their gemfiles haven't changed at all.
For reference:
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]
rails -v
Rails 3.2.6
rvm --version
rvm 1.1.4 by Wayne E. Seguin
And when I do gem list for the global and local gemsets, it shows bundler 1.1.0 installed.
Edit: I should also mention that running rails s starts up a WEBrick server just fine and I can access my apps at localhost:3000, so it's only under Passenger that this error crops up.
Have you committed your Gemfile.lock?
I was able to fix this by rolling back rubygems-update to the previously installed version by running
gem update --system 1.8.11
At which point all of my apps began working again. I'm still not sure what the problem was, and will gladly switch the accepted answer from my own to someone who can provide more insight into why updating rubygems-update would break Passenger integration.
I wish someone from Phusion Passenger would give a definitive answer but just wanted to say that I've experienced the same thing. Updating rubygems has broken passenger-nginx integration for us and requires recompiling the passenger-nginx module. Not sure why this would be. My speculation is that the module is somehow compiled with a hard reference to a specific version of rubygems.

Installed RVM and now my rails server won't start

I had started the Rails app yesterday and got everything working.
Then today I decided to go with RVM, as I realized I might have need of it. So I uninstalled all gems, installed RVM and have now a working(?) RVM.
I reinstalled the gems and now my bundle exec rails server crashes
$ bundle exec rails server
[BUG] cross-thread violation on rb_gc()
(null)
Abort trap: 6
Crashreport
I have no idea whats wrong with my installation, as there is no reasonable error' which I could understand. :(
Edit: Gemfile
Try adding gcc-4.2 as your default C compiler to your bash profile:
export CC=/usr/bin/gcc-4.2
Then reinstall your rubies. You need XCode 4.1 to be installed before 4.2, otherwise you won't have gcc-4.2. The easiest way is to uninstall 4.2, and then install 4.1, then upgrade to 4.2.
Check out this solution: Error: cross-thread violation on rb_gc()
It looks like this might be an issue with a ruby version difference between your system and RVM. There are a few other articles out there on how to clean this up, like the one below, but I'm not sure which one will work for you:
http://blog.ubrio.us/nix/osx-rubygems-and-cross-thread-violations-in-rb_gc/
Great, the answer was to use ruby 1.9.3 instead of 1.9.2 ...

rails command doesn't work

I've tried to start the rails server with this line:
$ rails s
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
...
create log/test.log
But if I write down this:
$ script/rails s
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:138: warning: Insecure world writable dir /usr/lib/ruby/gems/1.8 in PATH, mode 040777
=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
...
Anyone can see the problem? I think is a problem with environment variables, but I don't know how to fix it.
Thanks
I just came across this problem. I was switching from a Windows environment to Linux. My Linux version of rails is 2.3.14 while my Windows version was 3.0.1. On Windows "rails s" or "rails server" worked as expected to start a server, but on Linux it just created new projects with the names "s" and "Server" respectively. What finally explained it is the answer to the question below. Apparently the command behavior was changed between rails versions.
rails script/server doesn't start the server
The best solution is probably to update to the latest rails.
I was able to do that on my linux box by following the instructions below and using "sudo gem install rails"
http://installfest.railsbridge.org/installfest/ubuntu
http://root2linux.com/2011/01/install-rails-3-on-linux-mint-10/
this issue come from the different version in rvm, I faced this issue when my app was created using rvm 1.9.2 and I tried to run the server while rvm 1.9.3 was the running rvm version, simply switch to rvm1.9.2 and all will work properly (rvm use 1.9.2) in the terminal in ubunutu
Are you in a rails application directory? When you're running rails s make sure you've cd'd into the correct Rails directory. Common problem :)

Git, RVM, Ruby and Rails on OSX Tiger

I have an old laptop which runs OSX 10.4 Tiger where I'd like to run git, rvm, Ruby 1.9.2 and Rails 3.1.
At the moment I have git installed (using MacPorts), but rvm seems to require a newer version of bash. This I realized because the install script complains and I googled the error. Anyhow, I installed a newer bash with MacPorts and that helped me with getting rvm installed. However, it of course didn't replace the default bash version on the system and all rvm scripts point to the system one. This simply results in failures when I try to run any rvm commands.
Before I totally mess up the system I'd like to know does anyone have git, rvm, Ruby 1.9.2 and Rails 3.1 installed on OSX 10.4 Tiger? How did you install each part and what versions do you use?
Thanks for all help!
I never got this to work, but I decided to upgrade to OSX Snow Leopard. After this it was very easy to get things set up. This is what I recommend.