Vagrant Puppet set up failing to find class - module
Good day everyone,
I am giving vagrant a shot and pairing it with puppet to see if I can get a dummy project started. I am using provisioning scripts to install the necessary components in the ubuntu box I am spinning up on vagrant up command; however when puppet is provision it just fails and I don't know why, since I just started playing with it. My directory structure is as follows:
Project
|--puppet
|--manifests
|--site.pp
|--modules(empty)
|--Puppetfile
|--provision scripts
|--Vagrantfile
My provisioning scripts run the following commands
$as_vagrant = 'sudo -u vagrant -H bash -l -c'
${as_vagrant} apt-get update
${as_vagrant} gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
${as_vagrant} apt-get install curl -y
${as_vagrant} curl -sSL https://get.rvm.io | bash -s $1
rvm install 2.1.4
rvm use 2.1.4 --default
${as_vagrant} apt-get install -y puppet
${as_vagrant} gem install librarian-puppet -v 2.0.0
sudo apt-get install git -y
sudo touch /home/vagrant/metadata.json
sudo echo '{}' >> /home/vagrant/metadata.json
(I just threw all the commands in one block instead of breaking them up into their seperate files in order to keep this short)
My Puppetfile looks like this:
#!/usr/bin/env ruby
#^syntax detection
forge "https://forgeapi.puppetlabs.com"
# use dependencies defined in metadata.json
#metadata
# use dependencies defined in Modulefile
# modulefile
# Java module
mod 'tylerwalts/jdk_oracle'
# A module from the Puppet Forge
mod 'puppetlabs-stdlib'
# A module from git
mod 'puppetlabs-ntp',
:git => 'git://github.com/puppetlabs/puppetlabs-ntp.git'
# A module from a git branch/tag
mod 'puppetlabs-apt',
:git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
:ref => '1.4.x'
# A module from Github pre-packaged tarball
# mod 'puppetlabs-apache', '0.6.0', :github_tarball => 'puppetlabs/puppetlabs-apache'
The part of my vagrantfile that does runs the provision scripts looks like this:
##### Puppet management section
config.vm.provision :shell, :path => "install-rvm.sh", :args => "stable"
config.vm.provision :shell, :path => "install-ruby.sh", :args => "2.1.4"
config.vm.provision :shell, :path => "install-puppetstuff.sh"
config.vm.provision :shell, :path => "install-defaults.sh"
#Provisioning puppet
config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'puppet/manifests'
puppet.module_path = ['puppet/modules']
puppet.manifest_file = 'site.pp'
end
#Setting up librarian puppet for puppet modules
config.vm.provision :shell, :path => "librarian-puppet-init.sh"
Finally the librarian-puppet-init.sh script looks like this:
#!/usr/bin/env bash
librarian-puppet install
The site.pp file:
class { 'jdk_oracle':
versrion => '7'
}
Now, considering I didn't miss anything, that is my current 'set up' and when I do vagrant up everything runs well up until vagrant runs my librarian-puppet-init it script. When it executes it the whole thing crashes and it spits this out
==> default: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class jdk_oracle at /tmp/vagrant-puppet-3/manifests/site.pp:3 on node chard
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
puppet apply --modulepath '/tmp/vagrant-puppet-3/modules-0:/etc/puppet/modules' --manifestdir /tmp/vagrant-puppet-3/manifests --detailed-exitcodes /tmp/vagrant-puppet-3/manifests/site.pp
Stdout from the command:
warning: Could not retrieve fact fqdn
Stderr from the command:
stdin: is not a tty
Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class jdk_oracle at /tmp/vagrant-puppet-3/manifests/site.pp:3 on node chard
However, if I do not include anything in my site.pp file and instead leave it empty, I get this output(everything else stays the same)
==> default: Running provisioner: shell...
default: Running: /var/folders/jp/b91ydrmx1dx8kmvr0jvc78tw0000gn/T/vagrant-shell20141107-3334-likxg7.sh
==> default: stdin: is not a tty
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:74:in `metadata'
==> default: :
==> default: undefined method `each' for nil:NilClass
==> default: (
==> default: NoMethodError
==> default: )
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
==> default: from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell
Stdout from the command:
Stderr from the command:
stdin: is not a tty
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:74:in `metadata': undefined method `each' for nil:NilClass (NoMethodError)
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'
Anyone got any clue as to what is going on? I have spent days trying to figure out whats wrong and countless hours trying to find something on google that explains things clearly enough so that I have a squeaky clean set up, with no success. Any and all help is welcome. Thanks everybody.
*****EDIT******
I've moved my provision command for librarian puppet before the commands for provisioning puppet so my vagrant file looks like this now, and I've added a sync command:
##### Puppet management section
config.vm.provision :shell, :path => "install-rvm.sh", :args => "stable"
config.vm.provision :shell, :path => "install-ruby.sh", :args => "2.1.4"
config.vm.provision :shell, :path => "install-puppetstuff.sh"
config.vm.provision :shell, :path => "install-defaults.sh"
#Seting up librrian puppet for puppet modules
config.vm.provision :shell, :path => "librarian-puppet-init.sh"
#Provisioning puppet
config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'puppet/manifests'
puppet.module_path = ['puppet/modules']
puppet.manifest_file = 'site.pp'
end
#Syncs local chard folder with folder in box
config.vm.synced_folder "~/dev/chard", "/chard"
Now this is the puppet librarian output I get:
==> default: [Librarian] Ruby Version: 2.1.4
==> default: [Librarian] Ruby Platform: x86_64-linux
==> default: [Librarian] Rubygems Version: 2.4.2
==> default: [Librarian] Librarian Version: 0.1.2
==> default: [Librarian] Librarian Adapter: puppet
==> default: [Librarian] Librarian Adapter Version: 2.0.0
==> default: [Librarian] Project: /home/vagrant
==> default: [Librarian] Specfile: Puppetfile
==> default: [Librarian] Lockfile: Puppetfile.lock
==> default: [Librarian] Git: /usr/bin/git
==> default: [Librarian] Git Version: 1.7.9.5
==> default: [Librarian] Git Environment Variables:
==> default: [Librarian] (empty)
==> default: [Librarian] Specfile not found, using defaults: /home/vagrant/Puppetfile
==> default: [Librarian] Pre-Cached Sources:
==> default: Metadata file does not exist: /home/vagrant/metadata.json
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:70:in `metadata'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
==> default: /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
==> default: /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
==> default: /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
==> default: /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
==> default: /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell
Stdout from the command:
[Librarian] Ruby Version: 2.1.4
[Librarian] Ruby Platform: x86_64-linux
[Librarian] Rubygems Version: 2.4.2
[Librarian] Librarian Version: 0.1.2
[Librarian] Librarian Adapter: puppet
[Librarian] Librarian Adapter Version: 2.0.0
[Librarian] Project: /home/vagrant
[Librarian] Specfile: Puppetfile
[Librarian] Lockfile: Puppetfile.lock
[Librarian] Git: /usr/bin/git
[Librarian] Git Version: 1.7.9.5
[Librarian] Git Environment Variables:
[Librarian] (empty)
[Librarian] Specfile not found, using defaults: /home/vagrant/Puppetfile
[Librarian] Pre-Cached Sources:
Metadata file does not exist: /home/vagrant/metadata.json
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:70:in `metadata'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
/usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
/usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
/usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
/usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
/usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
/usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'
Stderr from the command:
stdin: is not a tty
/tmp/vagrant-shell: line 2: cd: /home/vagrant/chard: No such file or directory
That error would only happen if you are using the "metadata" command in the Puppetfile, or if there is no Puppetfile in the working dir but there is a metadata.json, and the metadata.json does not have a 'dependencies' section.
The Puppetfile you posted works fine here, check if librarian-puppet is being called in the correct dir and the metadata.json there is good
Related
No implicit conversion of nil into string Ruby Rails
I have some code that accesses an MLS listing service and downloads pictures into AWS. I am getting the error on MLS login. I'm on ruby 2.2.2p95 and rails 3.2.22. My code: AWS::S3::Base.establish_connection!( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY ) puts 'connected to AWS' client = Rets::Client.new({ login_url: LOGIN_URL, username: LOGIN, password: PASSWORD, version: VERSION }) begin client.login # rescue => e # puts 'Error: ' + e.message # exit! end The error: ➜ LiveByTransit git:(master) ✗ rake update_pics --trace ** Invoke update_pics (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute update_pics 66 connected to AWS rake aborted! TypeError: no implicit conversion of nil into String /home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml/document.rb:55:in `read_memory' /home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml/document.rb:55:in `parse' /home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml.rb:64:in `parse' /home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/parser/error_checker.rb:17:in `check' /home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/http_client.rb:20:in `http_get' /home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/client.rb:344:in `http_get' /home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/client.rb:63:in `login' /home/nitrous/code/LiveByTransit/lib/tasks/update_pics.rake:45:in `block in <top (required)>' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run' /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>' .bundle/binstubs/rake:16:in `load' .bundle/binstubs/rake:16:in `<main>' Tasks: TOP => update_pics ➜ LiveByTransit git:(master) ✗ ruby -v ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] ➜ LiveByTransit git:(master) ✗ rails -v Rails 3.2.22 In my code above, you'll see I commented out the error rescue. If I comment back in, the error looks like this: ➜ LiveByTransit git:(master) ✗ rake update_pics --trace ** Invoke update_pics (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute update_pics 66 connected to AWS Error: no implicit conversion of nil into String ➜ LiveByTransit git:(master) ✗ I've tried this suggestion with no change.
Devise Backbone Heroku and require.js on Rails configuration
Ok, so I know I am playing with the big boys and girls here messing with front and backend MVC (even though bbone isn't exactly MVC) for an application, but this is the first real robust application I have ever worked on, and unfortunately being in the academics realm, support isn't there, esp for more cutting edge, so I am thankful in advance. I have some errors when trying to deploy to Heroku with a Rails (3.2.2) app, and the asset pipeline has been causing problems all the time. Since I am using BBone for the front end, and the [single]page[app] needs to know the paths to images and sounds on load, I had to use this gist to attach the image paths to the App.assets to pass to the application.js file for require.js to start the application being built on the front end. The problem appears to be that Devise wants: config.assets.initialize_on_precompile = false while require wants: config.assets.initialize_on_precompile = true and Heroku wants in the production.rb file to be: config.assets.compile = true. The error I am getting is in the gist file assets.js.erb where the call is made to the DB to get all the songs in the Song model, second to last line App = {}; App.assets = { // Returns an object containing all of asset pipeline's image paths. // // Sample: // // { // avatars/missing_avatar.png: "/assets/avatars/missing_avatar.png" // chosen-sprite.png: "/assets/chosen-sprite.png" // circle_green.png: "/assets/circle_green.png" // circle_orange.png: "/assets/circle_orange.png" // circle_red.png: "/assets/circle_red.png" // circle_yellow.png: "/assets/circle_yellow.png" // document.png: "/assets/document.png" // } // // This hash is because Rails' Asset Pipeline bundles the routes to files // per user session, then hands that to the user's session browser, for security. // So we create in Ruby (erb = embedded ruby) a hash of the images to be accessed // in the JS. images: { <% AssetsUtil.images.each do |img| %> "<%= img %>" : "<%= asset_path(img) %>", <% end %> }, // Return a formatted URL for an asset. // // Sample: // // "/assets/document/png." // path: function(name) { // If the file is in our images object, pull the path from there. if (this.images && this.images[name]) { return this.images[name]; } // Otherwise, create a generic asset path. return '/assets/' + name; } }; // Currently this is ALL the songs in the DB, not just the current_user 's songs App.songs = { songs: <%= Song.all.to_json.html_safe %> }; The full trace error trying to rake assets:precompile as suggested todo before deploying to Heroku is: ** Invoke assets:precompile (first_time) ** Invoke requirejs:precompile:external (first_time) ** Invoke requirejs:test_node (first_time) ** Execute requirejs:test_node ** Execute requirejs:precompile:external /Users/me/.rvm/rubies/ruby-1.9.3-p362/bin/ruby /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace ** Invoke requirejs:precompile:all (first_time) ** Invoke requirejs:precompile:prepare_source (first_time) ** Invoke requirejs:setup (first_time) ** Invoke assets:environment (first_time) ** Invoke requirejs:precompile:disable_js_compressor (first_time) ** Execute requirejs:precompile:disable_js_compressor ** Execute assets:environment ** Execute requirejs:setup ** Invoke requirejs:clean (first_time) ** Invoke requirejs:setup ** Execute requirejs:clean ** Execute requirejs:precompile:prepare_source rake aborted! uninitialized constant Song (in /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb) /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:48:in `block in singletonclass' /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65530:in `instance_eval' /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65530:in `singletonclass' /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65528:in `__tilt_70168709646800' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:144:in `call' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:144:in `evaluate' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:77:in `render' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:177:in `block in evaluate' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `evaluate' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:12:in `initialize' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `new' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `block in build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:262:in `circular_call_protection' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:240:in `build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/bundled_asset.rb:16:in `initialize' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `new' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:94:in `block (4 levels) in <top (required)>' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:212:in `block in each_logical_path' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:200:in `block (2 levels) in each_file' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each_entry' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:198:in `block in each_file' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each_file' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:210:in `each_logical_path' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:92:in `block (3 levels) in <top (required)>' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' /Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain' /Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `load' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `<main>' Tasks: TOP => requirejs:precompile:all => requirejs:precompile:prepare_source rake aborted! Command failed with status (1): [/Users/me/.rvm/rubies/ruby-1.9.3-p362...] /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.2/lib/sprockets/assets.rake:12:in `ruby_rake_task' /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:85:in `block (3 levels) in <top (required)>' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' /Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain' /Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' /Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `load' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `<main>' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval' /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>' Tasks: TOP => assets:precompile => requirejs:precompile:external gemfile: source 'https://rubygems.org' gem 'rails', '3.2.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' group :development, :test do gem 'railroady' gem 'sqlite3' # For linux support gem 'therubyracer' end group :production do gem 'pg' gem 'thin' end # Gems used only for assets and not required # in production environments by default. group :assets do # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'uglifier', '>= 1.0.3' end # gem "better_errors", ">= 0.2.0", :group => :development # gem "binding_of_caller", ">= 0.6.8", :group => :development gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'jquery-rails' gem 'rails-backbone' gem "bootstrap-sass", "~> 2.3.0.0" gem 'requirejs-rails' gem 'ejs' gem 'devise' gem "better_errors", ">= 0.2.0", :group => :development gem "binding_of_caller", ">= 0.6.8", :group => :development gem 'color_routes' gem 'gon' So where should I start with my configuration to finish deployment? Potential info: If you watch how to make custom rake tasks from Railscasts here, the same error occurs when running the custom rake task, and Ryan explains that the task can't access the DB because the custom task needs an => :environment dependency (~4:15 in the movie) to access the User class. Since the precompile can't access the songs model, how could I provide the same or similar dependency to the application.js file? OTHER info: To my understanding the way the asset pipeline works is for each session, it bundles the paths (so when you type something like <%= link_to 'Sign in', new_user_path %>, rails defines those paths in the asset pipeline, and serves it to the user. Since Backbone is client side rendering, it needs to know the paths to the images and sounds after the page is handed from the rails server, and the only way to do this that I found was the gist listed above, where it bundles the "assets" to the JS, a similar approach to gem 'gon' that provides global variables to the page. I of course am plying in new grounds, and open to restructuring, but it works in dev mode, so I am trying to figure out production as well.
The Rails Environment is not available to you during heroku asset precompile. As they are made once and not refreshed again tell the next deploy. That being said. You should move your dynamic DB related calls to your views and render the data either via API calls or "bootstraping" the data by writing your Javascript ton a script tag in the dom in json. I normally have window.NAME_OF_APPLICATION.collections.SONGS so they are available to me in a global scope. Example. :javascript window.lineItems = {lineItems: #{ #order.line_items.order("position").to_json( :include => :department).html_safe}, order: #{#order.to_json} } When Backbone comes online have it call for these items. And initialize a collection for them.
#burningpony's accepted answer above is not entirely correct. The Rails env is available during heroku asset precompile if you use the labs plugin: https://devcenter.heroku.com/articles/labs-user-env-compile
rake aborted! undefined method `map' for :name:Symbol
I'm trying to pass arguments to a Rake task and access my model as mentioned in "How to pass command line arguments to a rake task" and "Do rails rake tasks provide access to ActiveRecord models?". However adding => :environment to this code: require 'rake' namespace :genre do desc "Add a genre" task :add, :genre_id, :name => :environment do |t, args| puts args.name end end Gives me this error when I run the task: rake genre:add['1','Abc'] rake aborted! undefined method `map' for :name:Symbol (See full trace by running task with --trace) If I delete => :environment it works just fine. UPDATE: TRACE: rake --trace genre:add['1','Abc'] rake aborted! undefined method `map' for :name:Symbol /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:254:in `set_arg_names' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task_manager.rb:29:in `define_task' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:310:in `define_task' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:32:in `task' /private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/lib/tasks/genre.rake:5:in `block in <top (required)>' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task_manager.rb:207:in `in_namespace' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:102:in `namespace' /private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/lib/tasks/genre.rake:3:in `<top (required)>' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `load' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `block in load_tasks' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `each' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `load_tasks' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:145:in `load_tasks' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing' /private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/Rakefile:7:in `<top (required)>' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' /Users/user/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load' /Users/user/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Looks like your syntax is off. Try: task :add, [:genre_id, :name] => :environment do |t, args|
rake undefined method `[]' for nil:NilClass
I just installed a Rails 3.1 app to my deployment server. When I tried to run sudo rake db:setup RAILS_ENV=“production” I got an error message saying rake aborted! undefined method `[]' for nil:NilClass With --trace it says: ** Invoke db:setup (first_time) ** Invoke db:create (first_time) ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:create rake aborted! undefined method '[]' for nil:NilClass /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:74:in 'rescue in create_database' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:54:in 'create_database' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:44:in 'block (2 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in 'call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in 'block in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in 'each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in 'execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:in 'block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in 'invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:176:in 'block in invoke_prerequisites' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in 'each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in 'invoke_prerequisites' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:157:in 'block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:201:in 'mon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in 'invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in 'invoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:in 'invoke_task' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'block (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in 'block in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in 'standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in 'top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in 'block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in 'standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in 'run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in '<top (required)>' /usr/local/bin/rake:19:in 'load' /usr/local/bin/rake:19:in '<main>' Tasks: TOP => db:setup => db:create My database.yml says production: adapter: mysql2 encoding: utf8 reconnect: false database: t_production pool: 5 username: deploy password: V host: localhost There is only 1 migration and it says this: class CreateDeals < ActiveRecord::Migration def change create_table :deals do |t| t.string :title t.text :description t.string :image_url t.decimal :price, :precision => 8, :scale => 2 t.timestamps end end end What should I try to fix this? I'm not even sure where to begin.
You should fix your statement, the double quotes are wrong. They need to be regular " quotes. It probably tries to load a setting for the “production” environment, which obviously doesn't exist. If you are using the correct quotes, make sure your identation is correct, the definition should look something like the following: production: adapter: mysql2 encoding: utf8 reconnect: false database: t_production pool: 5 username: deploy password: V host: localhost
Rails 3 Setting Up Action Mailer
Everything was going so well... gem 'mail' is installed enter > $ rails g scaffold user name:string email:string enter > $ rake db:migrate (fine I can see it on http://localhost:3000/users/new) then... enter > $ rails g mailer user_mailer On this command I get this huge error - what is it and how do I resolve it? Users/mailer_app/config/initializers/setup_mail.rb:14: uninitialized constant DevelopmentMailInterceptor (NameError) from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:201 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:200:in `each' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:200 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `instance_exec' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `run' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:50:in `run_initializers' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `each' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `run_initializers' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:134:in `initialize!' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `send' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing' from /Users/liam_carey/Documents/Aptana Studio 3 Workspace/mailer_test/config/environment.rb:5 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:103:in `require' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:103:in `require_environment!' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:16 from script/rails:6:in `require' from script/rails:6 user:mailer_app $
Here is the contents of my config/initializers/setup_mail.rb Am using Heroku and Sendgrid and have installed the plug-in. Did I need to install the 'mail' gem first, the documentation doesn't mention it?? ActionMailer::Base.smtp_settings = { :address => "smtp.sendgrid.net", :port => "25", :authentication => :plain :user_name => "apxxxxx#heroku.com", :password => "9XXXXXXXXX", :domain => "www.myapp.com", } I know what the issue is now - there is no comma after the user-name and password entries!