Install Nodejs for V8 Rails to use Less - ruby-on-rails

I tried to install Bootstrap for Rails, but i always got this error:
Please install gem 'therubyracer' to use Less.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/less-2.4.0/lib/less/java_sc
ript/v8_context.rb:2:in `require': cannot load such file -- v8 (LoadError)
To avoid this problem i installed nodejs and added this line in config/boot:
ENV['EXECJS_RUNTIME'] = 'Node'
So when i restart my webrich server i see on public indey that the javascript runtime now is nodejs. Then i reapeted the installation of twitter bootstrap but get the same error. I use Rails 4.0 and hope that somebody has an advice for me? Thanks

For Javascript runtime in Rails : Dont use the 'therubyracer' or 'execjs' in your gem files.
First remove those in ur Gemfile and and Remove Gemfile.lock.
After that do this following installation for nodejs.
sudo apt-get install nodejs
I am considering your environment as ubuntu/linux. So for that use above command
And Bundle your app.
Hope this will help you.

Related

Linux Rails Gem Install Error

Does anyone know what's happening here?
root#ip-172-31-5-114:/home/bitnami/htdocs/kicksharer/kickscraper# gem install rails
Successfully installed rails-5.0.0.1
Parsing documentation for rails-5.0.0.1
Done installing documentation for rails after 0 seconds
1 gem installed
root#ip-172-31-5-114:/home/bitnami/htdocs/kicksharer/kickscraper# bundle show rails-5.0.0.1
Could not find gem 'rails-5.0.0.1'.
Any suggestions for troubleshooting would be really appreciated.
When you gem install rails it installs it on your system. You need to make sure rails is specified in your gem file and then bundle install in order to install those gems in the bundle. (It should use the already installed gems on your system)

Ruby on Rails error during installation

I'm trying to install Ruby, I followed the installation guide well, but when I tried to run the server by the command:
ruby bin/rails setup
after I created the controller called blog as described in the instructions, it gave me an error in red and a text in yellow:
Error:
Could not find gem uglifier <>= 1.3.0 in the gems available on the machine.
Yes! I know that this is a Googleable question but all I can get are solutions for people with internet access on their PC.
But unfortunately, my computer doesn't have a working Internet connection. I'm posting this question from my phone. So I'm unable to install uglifier(if that's the required thing to do) through the command prompt. Many thanks.
Please could you check if your Gemfile has the following gem
gem 'uglifier'
If the Gem is not present add it to your Gemfile, if you already have it in your Gemfile please run:
bundle install
After that you should check if the bundler is installing the uglifier gem.
Hope that helps,

uglifier gem load error / download node.js?

I am getting started with Ruby on Rails, and following the steps at InstallRails... I have created the sample_app on the desktop, and now I cannot create the server.
My command
$ rails server
is answered with the following
...There was an error while trying to load the gem 'uglifier'. etc
I have read several threads here and elsewhere, such as this one and this one... In the latter there seems to bea solution, which I can't understand.... I cannot download node.js! or nodejs? What is my command and directory in Gitbash to download it?
It requires JS runtime.
Just install gem therubyracer for the JS runtime.
In the default rails Gemfile,uncomment the line for the gem 'therubyracer' which is commented out.If you dont find it add the gem to your Gemfile like
gem 'therubyracer'
Then run
bundle install
The gem will be installed and it should work.
Otherwise you can install node.js.
For ubuntu
sudo apt-get install nodejs
For mac
brew install nodejs

Could not find a valid gem 'mysql2-0.3.18.gem'

i am new to Ruby on rails and i have facing this problem during Rails installation. I have searched a lot and tried many solution which were available on stackoverflow but nothing work for me. Please help how can i get out of this problem..
I have had this problem before, and the reason you are getting this method, is because you are trying to download from an https website.
My guess is you are trying to install all the gems in your gemfile and bundle install didn't work. It would give you a message like
bundler cannot continue. Please make sure gem install samplegem succeeds
Change the following line in your gemfile
source 'https://rubygems.org'
to
source 'http://rubygems.org'
and run bundle
alternatively, you could do the following
gem install mysql2 -s http://rubygems.org
Either way, you should be able to install the gem.
Had you already installed mysql in your machine? The same experiencing happened with me. I was using a virtual environment and trying to install gem mysql2 but I forget that I haven't mysql in my "main" environment.
I ran the following and mysql2 installed successfully.
gem install mysql2 -s http://rubygems.org
But the problem remaied the same when re ran the "bundle install"

Unable to install gem with the proxy option

Trying to solve this issue I have a solution telling that using the proxy option when installing gem will help.
I am executing the following line:
sudo gem install rails --http-proxy=http://rubygems.org/
but it give me the same error:
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: Possible alternatives: rails
Could anyone tell what I am doing wrong?
The HTTP proxy isn't rubygems... if you espesify a proxy so... you have to put your own proxy... if you have not proxy... so don't put http-proxy... =)
Do first
REALLY_GEM_UPDATE_SYSTEM=1 sudo gem update --system
sudo gem install rails
In both question -also question from - Ruby is installed by package managers like Synaptic, Aptitude. Debian-like operating systems stricts installation of gems without using package manager. You may use REALLY_GEM_UPDATE_SYSTEM with installation of gems like, but not recommended:
gem install rails REALLY_GEM_UPDATE_SYSTEM=true
Instead of that, you should prefer using RVM or rbenv to get rid of package manager based installation

Resources