rake db:migrate depreciated...what do I do? - rake

I tried updating the gems. I discovered the problems after trying to do heroku rake db:migrate and it said:
rake aborted!
no such file to load -- faker
/app/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)
Then when I do rake db:migrate it says:
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/shared_helpers.rb:84.
Not quite sure what i'm doing wrong.

I figured it out. I'm not sure why this happened all of a sudden randomly but rolling back to an earlier version of rubygems solved the issue. Here's the code:
sudo gem update --system 1.6.2

Related

How to setup rake to compile mruby gems?

I am trying to build the example gem from here following the mruby documentation for building gems.
I'm on a Mac OS Catalina, and I have installed RVM to manage my installation mruby. Right now which ruby returns /Users/mdorier/.rvm/rubies/mruby-2.0.1/bin/ruby so I can see that mruby is used.
The example gem above has an mrbgem.rake file, so even though the documentation doesn't explain how to build the gem, I suppose rake should be invoked in that directory. I didn't have rake installed, so I tried to install it with gem install rake, but it seems that Mac OS's native gem executable in /usr/bin got invoked, apparently installing the normal ruby's rake gem. When I call that rake, it doesn't find a Rakefile in the directory. If I specify rake -f mrbgem.rake, it tells me NameError: uninitialized constant MRuby.
I see that mruby doesn't have a gem command but seems to have a mgem that can be installed with gem. I installed it. I see that there is a mruby-rake mgem available, which I activated using mgem add mruby-rake, but it doesn't change what the rake command points to.
Can someone explain how I can install and use the proper rake command to build this mruby gem?

Bundle with capistrano installed by chef

I'm configuring a vagrant box using chef and then deploying my app using capistrano.
my chef recipe to install bundler is the following:
include_recipe "rbenv"
include_recipe "rbenv::ruby_build"
rbenv_ruby node[:rbenv][:ruby] do
global true
end
rbenv_gem "bundler" do
ruby_version node[:rbenv][:ruby]
end
using the Riot rbenv cookbook
When I try using the bundle with capistrano I figured that the executed bundle is one that was preinstalled on the box, rather than the one installed by chef.
Here's the problem:
$ which bundle
/opt/rbenv/shims/bundle
$ sudo which bundle
/usr/bin/bundle
$ sudo su -
root# which bundle
/opt/rbenv/shims/bundle
Basically it appears that Capistrano runs the commands using the second form, were it uses the /usr/bin/bundle.
I've tried running:
$ sudo bundle
/usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8:in `require': no such file to load -- rubygems (LoadError)
from /usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8
from /usr/lib/ruby/vendor_ruby/bundler.rb:11:in `require'
from /usr/lib/ruby/vendor_ruby/bundler.rb:11
from /usr/bin/bundle:4:in `require'
from /usr/bin/bundle:4
and I obtain exactly the same exception I see in Capistrano.
If I manually uninstall bundler then here's what I obtain:
$ bundle
Bundler::GemfileNotFound
$ sudo bundle
sudo: bundle: command not found
$ sudo su -
root# bundle
Bundler::GemfileNotFound
UPDATE
I've figured that the whole ruby version is not available for sudoers:
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
$ sudo ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
even more troubles.
Can you help me ?
thanks.
The problem is not that the rbenv-managed Ruby is not available to sudoers. The problem is that the system Ruby is used by default, unless overridden by something else -- usually .bashrc or a /etc/profile.d/* or such.
Since capistrano doesn't source any of these files, it uses the system Ruby.
You should tell cap to use the rbenv bin paths before the system ones by adding:
set :default_environment, {
'PATH' => "/opt/rbenv/shims:/opt/rbenv/bin:$PATH"
}
to your deploy.rb file.
Update
In Capistrano v3, the :default_environment has been renamed to :default_env.
Apparently tweaking with the default_env is a possibility, but not the preferred way.
as:
set :default_environment, {
'PATH' => "/opt/rbenv/shims:/opt/rbenv/bin:$PATH"
}
is not maintained by capistrano and probably even dangerous.
The preferred way is to look into the program one wants to run for a way to fix this.
In particular my problem: the RVM needs to be initialized upon shell startup, and any RVM installation tool will include your .bashrc with the call to the proper init script at the end of the file. Also at the beginning of .bashrc there's a command that exits the script when it's called on a non interactive shell.
Accidentally Capistrano runs the scripts on a non interactive shell, so when it calls RVM commands they are not initialized, in the non interactive shell.
The solution in my case was to edit the .bashrc file in chef so to call the RVM init script before exiting.

Travis CI for Github?

I have a minimalistic .travis.yml file, which consists of:
php:
- "5.4"
But on console, it fails with:
$ rvm use default --install --binary --fuzzy
Using /home/travis/.rvm/gems/ruby-1.9.3-p448
$ ruby --version
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
$ rvm --version
rvm 1.21.3 (latest-minor) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
$ gem --version
2.0.3
$ rake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/home/travis/.rvm/gems/ruby-1.9.3-p448#global/bin/ruby_noexec_wrapper:14:in `eval'
/home/travis/.rvm/gems/ruby-1.9.3-p448#global/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
The command "rake" exited with 1.
Done. Your build exited with 1.
It's defaulting to ruby when I have specified PHP as the language, whats wrong here ?
Try making your .travis.yml a little less minimalist:
language: php
php:
- 5.4
Also, using php with travis uses phpenv instead of rvm
Read up more on it here:
http://about.travis-ci.org/docs/user/languages/php/
It took me some time to figure out so I'm posting here for anyone else that may encounter this in the future:
I had no idea that, in YAML, whitespace has meaning. Tabs/spaces (and possibly \r\n ("windows") vs \n ("linux")) matter. A simple change I did to my .yml file made a night-and-day difference (build failed before, built correctly after).
Lesson learned here: YAML cares about whitespace. Make sure your .travis.yml file is correct!

building ember.js with rake

I'm trying to learn ember so I created a local git repository cloned from github so I could stay up to date with it. I've never used rake before so I also downloaded and installed that from http://rake.rubyforge.org/. Rake appeared to install correctly and when I ran rake --help I got the help options so I think it's all okay. So then in my command prompt, I did a CD to the directory that has the github files for ember. From my reading, since there's a Rakefile in the ember directory it sounds like I can just CD to that directly and run rake. But when I do that I get the following errors. I'm sorry but I have no experience with rake so I'm not sure what I am doing wrong... or if it's something in the build file?
c:\inetpub\wwwroot\dev\js\ember.js>rake
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rake/rake_module.rb:25: warning: redundant nested repeat operator
c:/inetpub/wwwroot/dev/js/ember.js/Rakefile:485: warning: ambiguous first argument; put parentheses or even spaces
c:/inetpub/wwwroot/dev/js/ember.js/Rakefile:487: warning: ambiguous first argument; put parentheses or even spaces
rake aborted!
cannot load such file -- bundler/setup
c:/inetpub/wwwroot/dev/js/ember.js/Rakefile:3:in `<top (required)>' (See full trace by running task with --trace)
c:\inetpub\wwwroot\dev\js\ember.js>
You need to install bundler (so you can get all of the gems ember's rake tasks depend on).
gem install bundler
Then, inside your ember directory:
bundle install
rake -T

rake snorby:setup

while running:
rake snorby:setup
getting below error:
rake aborted!
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.
(See full trace by running task with --trace)
Please help.
Try
bundle exec rake snorby:setup
this error derived from the fact that you have multiple versions of rake gem, even newer than the one required by your Gemfile.
You can see this by typing
gem list rake
that should print on your console something like this:
*** LOCAL GEMS ***
rake (0.9.2.2, 0.8.7)
since rake is a tool you launch from the outside of a Rails (bundler) environment, it cannot know anything about bundle version unless you explicitly specify to follow bundler's version directions with the bundle exec command.