Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config file problem: local_variables not being loaded on ruby 1.9.x #3

Open
victorhg opened this issue Jun 12, 2010 · 3 comments
Open

Comments

@victorhg
Copy link

Hello,
I'm using ruby 1.9.1-p376 and have tried this with 1.9.2

The project is configured fine, but when I execute

victorhg$ inploy setup
/Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/dsl.rb:48:in `remote_run': undefined method `each' for nil:NilClass (NoMethodError)
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/deploy.rb:48:in `remote_setup'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/cli.rb:9:in `execute'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/bin/inploy:7:in `<top (required)>'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `load'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `<main>'

Here's my config/deploy.rb file:

template = :rails3
application = "myProject"
repository = '[email protected]:user/project.git'
hosts = ['server']

path = '/var/www/'
user = 'rails'

Explaining the problem:

Well, because of the change on how eval method handles local variables, we cannot have something like this on ruby 1.9:

eval "variable = 1"
print variable

The way inploy handles the configuration parameters is not working (at least for me). Here is the problem in the code:

inploy/deploy.rb:27

def configure
    if file = configuration_file
      deploy = self
      eval file.read
      local_variables.each do |variable
        send "#{variable}=", eval(variable) rescue nil
      end
    end
  end

When executing eval file.read the variables are not created as local variables, but only as local variables inside the eval scope. To solve this, I had to change the config/deploy file to created instance variables:

@template = :rails3
@application = "myProject"
@repository = '[email protected]:user/project.git'
@hosts = ['server']

@path = '/var/www/'
@user = 'rails'

Maybe there's a better way to make it work... or I would be really glad to hear that it's just some stupid mistake I did....

thank you...

@dcrec1
Copy link
Owner

dcrec1 commented Jun 12, 2010

Hi Victor, you're right.

I'm gonna try to resolve this. Another syntax you can use is the old one:

deploy.user = 'rails'
...

Thanks for the alert.

@victorhg
Copy link
Author

One possibility is to pre-define the variables.

Although this doesn't work:

eval "variable = 1"
print variable

If you define the variables before, it will work:

variable = 10
eval "variable = 55"
print variable
==> 55

Cheers..

@dcrec1
Copy link
Owner

dcrec1 commented Jun 12, 2010

I thought to do this but the problem is that every time an attribute is declared, the person would have to remember to declare it also as a local variable in the configure method.

I applied a hack and it should be working now. Anyway, please send me a patch if you got a better implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants