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

build_command': undefined method shellescape' for nil:NilClass #158

Closed
hiyosi opened this issue Aug 24, 2015 · 8 comments · Fixed by #192
Closed

build_command': undefined method shellescape' for nil:NilClass #158

hiyosi opened this issue Aug 24, 2015 · 8 comments · Fixed by #192

Comments

@hiyosi
Copy link

hiyosi commented Aug 24, 2015

Once I have upgraded itamae from 1.2.11 to 1.4.5 the following error is generated.
It seems to occur if user attribute in the link resource or service resource is specified .
However, there is described about user attribute in the wiki page. so, Which behavior is correct?

/Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/backend.rb:180:in `build_command': undefined method `shellescape' for nil:NilClass (NoMethodError)
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/backend.rb:46:in `run_command'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/resource/base.rb:294:in `run_command'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/resource/base.rb:271:in `do_not_run_because_of_not_if?'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/resource/base.rb:130:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/logger.rb:31:in `with_indent'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/logger.rb:38:in `with_indent_if'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/resource/base.rb:126:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:60:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `each'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe.rb:53:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/logger.rb:31:in `with_indent'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe.rb:52:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:62:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `each'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe.rb:53:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/logger.rb:31:in `with_indent'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe.rb:52:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:62:in `block in run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `each'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/recipe_children.rb:57:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/runner.rb:53:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/itamae-1.4.5/lib/itamae/runner.rb:23:in `run'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-itamae-0.1.0/lib/vagrant-itamae/provisioner.rb:16:in `provision'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:133:in `run_provisioner'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:428:in `hook'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:121:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:121:in `block in call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:103:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/provision.rb:103:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/upload.rb:13:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/install.rb:10:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/save.rb:10:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:15:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/set_name.rb:50:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/match_mac_address.rb:16:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/import.rb:32:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/share.rb:10:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/load.rb:10:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/env_set.rb:19:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /Users/hiyosi/.vagrant.d/gems/gems/vagrant-berkshelf-4.0.4/lib/vagrant-berkshelf/action/check.rb:12:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in `action_raw'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in `block in action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in `lock'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
        from /opt/vagrant/embedded/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
        from /opt/vagrant/embedded/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
@ryotarai
Copy link
Member

Thank you for reporting. Would you give me a recipe code to reproduce the error?

@hiyosi
Copy link
Author

hiyosi commented Aug 24, 2015

For example , it is a recipe such as the following

group 'create ham group' do
  action :create
  groupname 'ham'
  gid 602
end

user 'create ham user' do
  action :create
  username 'ham'
  password '*'
  uid 602
  gid 602
end

directory '/var/local' do
  action :create
  owner 'ham'
  group 'ham'
end

directory '/var/local/etc' do
  action :create
  owner 'ham'
  group 'ham'
end

template '/var/local/etc/logrotate.d/my-service' do
  owner 'ham'
  group 'ham'
  mode '644'
  notifies :run, 'execute[update logrotate conf]'
end

link '/etc/logrotate.d/my-service' do
  user 'root'
  to '/var/local/etc/logrotate.d/my-service'
  not_if 'test -h /var/local/etc/logrotate.d/my-service'
end

execute 'update logrotate conf' do
  action :nothing
  command '/usr/sbin/logrotate /etc/logrotate.conf'
end

@ryotarai ryotarai reopened this Aug 27, 2015
@ryotarai
Copy link
Member

Thank you. I'll try to reproduce the problem.

@yuichiro-naito
Copy link
Contributor

I'm facing same problem, too.
For itamae-1.6.3, I wrote a small patch like this.

--- backend.rb.org      2016-01-06 11:13:42.917225276 +0900
+++ backend.rb  2016-01-06 11:14:46.370225260 +0900
@@ -176,6 +176,7 @@

         user = options[:user]
         if user
+          shell||='/bin/sh'
           command = "cd ~#{user.shellescape} ; #{command}"
           command = "sudo -H -u #{user.shellescape} -- #{shell.shellescape} -c #{command.shellescape}"
         end

The 'shell' variable is undefined in this scope.

@hico-horiuchi
Copy link
Contributor

You can avoid errors by adding configuration to Vagrantfile like below.

config.vm.provision :itamae do |config|
  config.shell = '/bin/sh'
end

@yuichiro-naito
Copy link
Contributor

Is 'config.shell' requirement option for vagrant plugin?

@hico-horiuchi
Copy link
Contributor

@yuichiro-naito shell seems like optional.
But the error occured when user attribute is used, if shell option isn't set.
(Is it better that we discuss at chiastolite/vagrant-itamae ?)

@yuichiro-naito
Copy link
Contributor

@hico-horiuchi Thanks for the answer.
I found #192 pull request.
I think it will fix this problem.

ryotarai added a commit that referenced this issue Jan 24, 2016
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

Successfully merging a pull request may close this issue.

4 participants