where does rails' "rake assets:precompile" source code live? - ruby-on-rails-3.1

Can't find it in railties
Can only find part of it in sprocketstask
Where to look?

Rake task itself is defined here in sprokets-rails gem.

In rails 3.2.6 you can find it with gem contents actionpack | grep rake

Related

Ruby cannot load any gem that I install (Ubuntu server)

I've got a simple script that uses sinatra. Should be simple, right? Apparently not.
The code:
require 'rubygems'
require 'sinatra'
That's all there is. And it fails, saying:
tekknolagi#eos ~/indexer $ ruby torrent.rb
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- torrent-ruby (LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from torrent.rb:2
I gem installed it several times over, just to make sure I wasn't going crazy. What could be going wrong and how can I fix it?
Oh, and here's my list of installed gems:
tekknolagi#eos ~/indexer $ gem list
*** LOCAL GEMS ***
rack (1.4.1)
rack-protection (1.2.0)
rake (0.9.2.2)
sinatra (1.3.2)
sqlite3 (1.3.6)
tilt (1.3.3)
torrent-ruby (0.1.4)
I believe you have done everything right. Many times this custom require error appears when the gem is not installed in the proper path. Try not using the explicit require. Use this instead..:
require_relative 'sinatra'

Rails Gem Issue

I just installed Rails 3.2.1 with Ruby 1.9.3p0
davesahil#sahil-pc:~$ gem list rails
*** LOCAL GEMS ***
rails (3.2.1)
$rails --version gives me this
/home/davesahil/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:314:in `bin_path': can't find gem rails ([">= 0"]) with executable rails (Gem::GemNotFoundException)
from /home/davesahil/.rvm/gems/ruby-1.9.3-p0/bin/rails:19:in `<main>'
Its been a while since I last worked on rails. Am I missing something over here?
I had the same problem with rails 3.2.1 and ruby 1.8.7.
The following worked for me :
sudo gem install railties

Ruby on Rails - New to Ruby help with rake db:migrate

I am a new user to Ruby on Rails and am having an issue with: rake db:migrate.
After I bundle install, the following comes up:
$ bundle install
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using bundler (1.0.18)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using sqlite3-ruby (1.2.5)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Then, when I try and rake db:migrate, i get the following:
$ rake db:migrate
Could not find polyglot-0.3.2 in any of the sources
Run `bundle install` to install missing gems.
Anyone have any advice? Thanks.
I am on ruby 1.8.7 and rails 3.0.9
Check where it's installed:
gem list -d polyglot
Run bundle exec to make sure rake uses what's specified in your gemfile:
bundle exec rake db:migrate
Ya..apparently the polyglot gem is not included in your gem file.
Also try doing gem install polyglot...
Hope it helps !
bundle exec rake db:migrate might help too..

Rake 0.8.7 and ActiveSupport 3.0.1

I am running Ruby 1.9.2. I have rake 0.8.7 installed. However running rake inside a Rails application gives me the following:
(in /usr/home/users/dimitar/Rails/spek)
Could not find activesupport-3.0.1 in any of the sources
Try running `bundle install`.
So I go ahead and run bundle install again and everything looks good:
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.1)
Using builder (2.1.2)
Using i18n (0.4.1)
Using activemodel (3.0.1)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.6)
Using tzinfo (0.3.23)
Using actionpack (3.0.1)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.8)
Using mail (2.2.7)
Using actionmailer (3.0.1)
Using arel (1.0.1)
Using activerecord (3.0.1)
Using activeresource (3.0.1)
Using bundler (1.0.3)
Using thor (0.14.3)
Using railties (3.0.1)
Using rails (3.0.1)
Using sqlite3-ruby (1.3.1)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
But rake still gives me the same error message. Any suggestions?
Actually the problem seems to come from the config/boot.rb file:
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
Do you have multiple Ruby interpreters installed (maybe via rvm or some other method)? If so, are you sure that the right one is active?
Things to look at:
which ruby
which rake
ruby -e 'puts $:' # To show the LOAD_PATH for gems
I had a similar problem using ruby-1.9.2 and fixed it by upgrading rubygems
sudo gem update --system
I had the same problem when I was using REE 1.8.7. I switched to 1.9.2 and did bundle install. Then my rake commands worked.
I had this issue when I mistakenly ran passenger with ruby 1.9.3 and the app used 1.8.7 in its .rvmrc. Fixed by using 1.9.3 (now I have encoding problems, but thats a different story).

Could not locate Gemfile

I'm certainly no Ruby developer but I have an application on my server using Ruby, Gems, and Bundler. I am trying to install another Ruby on under a different user account but on the same VPS. When I go to run
bundle install
I get the following error:
Could not locate Gemfile
I could remove the contents of the ./bundle directory so that all Gems are re-fetched to clear the error but will this have an impact on my other application using the same Gems and Bundler? I don't want to risk taking the other app down.
You do not have Gemfile in a directory where you run that command.
Gemfile is a file containing your gem settings for a current program.
Make sure you are in the project directory before running bundle install. For example, after running rails new myproject, you will want to cd myproject before running bundle install.
I had the same problem and got it solved by using a different directory.
bash-4.2$ bundle install
Could not locate Gemfile
bash-4.2$ pwd
/home/amit/redmine/redmine-2.2.2-0/apps/redmine
bash-4.2$ cd htdocs/
bash-4.2$ ls
app config db extra Gemfile lib plugins Rakefile script tmp
bin config.ru doc files Gemfile.lock log public README.rdoc test vendor
bash-4.2$ cd plugins/
bash-4.2$ bundle install
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.3.6)
Using activesupport (3.2.11)
Using builder (3.0.0)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.1)
Using actionpack (3.2.11)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.11)
Using activeresource (3.2.11)
Using coderay (1.0.6)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.15.4)
Using railties (3.2.11)
Using jquery-rails (2.0.3)
Using mysql2 (0.3.11)
Using net-ldap (0.3.1)
Using ruby-openid (2.1.8)
Using rack-openid (1.3.1)
Using bundler (1.2.3)
Using rails (3.2.11)
Using rmagick (2.13.1)
Your bundle i
I solved similar problem just by backing out of the project directory, then cd back into the project directory and bundle install.
Is very simple. when it says 'Could not locate Gemfile' it means in the folder you are currently in or a directory you are in, there is No a file named GemFile. Therefore in your command prompt give an explicit or full path of the there folder where such file name "Gemfile" is e.g cd C:\Users\Administrator\Desktop\RubyProject\demo.
It will definitely be solved in a minute.
I had to do touch Gemfile.
My case was an AWS Amazon Linux instance and Capistrano setting up Puma.
Here is something you could try.
Add this to any config files you use to run your app.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
Bundler.require(:default)
Rails and other Rack based apps use this scheme. It happens sometimes that you are trying to run things which are some directories deeper than your root where your Gemfile normally is located.
Of course you solved this problem for now but occasionally we all get into trouble with this finding the Gemfile. I sometimes like when you can have all you gems in the .bundle directory also.
It never hurts to keep this site address under your pillow.
http://bundler.io/
In my case, I was trying to run locally checked out rails code in a script
gem "rails", path: "../rails"
Running the script normally as ruby script.rb gave the error Could not locate Gemfile or .bundle/ directory (Bundler::GemfileNotFound)
Setting the Gemfile path similar to #douglasgallen solved it
BUNDLE_GEMFILE="../rails" ruby script.rb
Typo
Maybe a stupid solution, but I got a typo: Gemfile instead of GemFile. Hope this helps.

Resources