Giter Site home page Giter Site logo

composer's Introduction

composer cookbook

Description

This cookbook provides an easy way to install Composer, a dependency manager for PHP.

More information available at http://getcomposer.org/.

Requirements

⚠ This cookbook does not install PHP! Please make sure PHP is installed before this cookbook is included, e.g. by using the php cookbook.

Cookbooks:

No dependencies.

Platforms:

  • Ubuntu
  • Debian
  • RHEL
  • CentOS
  • Fedora
  • Windows

Attributes

  • node['composer']['url'] - Location of the source
  • node['composer']['install_dir'] - Installation target directory (absolute or relative path) if installing locally
  • node['composer']['bin'] - bin directory
  • node['composer']['install_globally'] - Installation method, :source or :package - default true
  • node['composer']['mask'] - Mask for composer.phar - default 0755
  • node['composer']['link_type'] - link type for composer.phar link - default :symbolic
  • node['composer']['global_configs'] - Hash with global config options for users, eg. { "userX" => { "github-oauth" => { "github.com" => "userX_oauth_token" }, "vendor-dir" => "myvendordir" } } - default {}
  • node['composer']['home_dir'] - COMPOSER_HOME, defaults to nil (in which case install_dir will be used), please do read the Composer documentation on COMPOSER_HOME when setting a custom home_dir
  • node['composer']['global_install']['install_dir'] - The default location to install the packages in for composer_install_global
  • node['composer']['global_install']['bin_dir'] - The default location to symlink the binaries when using composer_install_global

Resources

This cookbook includes resources for managing a Composer project and for installing Composer packages globally:

composer_project

Actions

Action Description
:install Reads the composer.json file from the current directory, resolves the dependencies, and installs them into project directory - this is the default action
:require Create composer.json file using specified package and version and installs it with the dependencies.
:update Gets the latest versions of the dependencies and updates the composer.lock file
:dump_autoload Updates the autoloader without having to go through an install or update (eg. because of new classes in a classmap package)
:remove Removes package from composer.json and uninstalls it

Properties

Name Description
project_dir The directory where your project's composer.json can be found (name attribute)
package The package to require or remove when using those actions
version The version of the package to require or remove when using those actions, default *.*.*. Be careful when uninstalling, the version has to match the installed package!
vendor Can be used to combine package and version, deprecated!
dev Install packages listed in require-dev, default false
quiet Do not output any message, default true
optimize_autoloader Optimize PSR0 packages to use classmaps, default false
prefer_dist use the dist installation method
prefer_source use the source installation method
bin_dir overwrites the composer bin dir
user the user to use when executing the composer commands
group the group to use when executing the composer commands
umask the umask to use when executing the composer commands
environment A hash of environment variables that will be available when running composer

Examples

# Install the project dependencies
composer_project "/path/to/project" do
  dev false
  quiet true
  prefer_dist false
  action :install
end

# Require the package in the project dir
composer_project "/path/to/project" do
  package 'vendor/package'
  version '*.*.*'
  dev false
  quiet true
  prefer_dist false
  action :require
end

# Update the project dependencies
composer_project "/path/to/project" do
  dev false
  quiet true
  action :update
end

# Dump-autoload in the project dir
composer_project "/path/to/project" do
  dev false
  quiet true
  action :dump_autoload
end

# Remove the package in the project dir
composer_project "/path/to/project" do
  package 'vendor/package'
  action :remove
end

composer_install_global

Actions

Action Description
:install Installs the package in the preferred global composer directory, putting binary symlinks in the preferred global binary directory (see attributes)
:update Gets the latest versions of the dependencies and updates the composer.lock file for the globally installed composer packages
:remove Removes package from the global composer.json and uninstalls it

Attribute parameters

Property Description
package The package to install or remove, name_attribute
version The version of the package to install or remove when using those actions, default *.*.*. Be careful when uninstalling, the version has to match the installed package!
install_dir the directory in which to make the global installation, default: see the attributes
bin_dir the directory in which to make the symlinks to the binaries, default: see the attributes
dev Install packages listed in require-dev, default false
quiet Do not output any message, default true
optimize_autoloader Optimize PSR0 packages to use classmaps, default false
prefer_dist use the dist installation method
prefer_source use the source installation method

Examples

# Install a package globally
composer_install_global "package" do
  version '~4.1'
  action :install
end

# Update the package
composer_install_global "package" do
  action :update
end

# Remove the package from the global installation
composer_install_global "package" do
  action :remove
end

Usage

  1. Make sure PHP is installed (e.g. include the php::default recipe)
  2. Set custom values for any attributes in a wrapper recipe / node data
  3. Include composer::default in your wrapper recipe / run list
  4. Use composer_project and composer_install_global in your recipes

References

License and Authors

Author: David Joos [email protected] Copyright: 2016-2022, David Joos

Author: David Joos [email protected] Author: Escape Studios Development [email protected] Copyright: 2012-2015, Escape Studios

Unless otherwise noted, all files are released under the MIT license, possible exceptions will contain licensing information in them.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

composer's People

Contributors

andygrunwald avatar arosenhagen avatar bezhermoso avatar daften avatar dazwin avatar detjensrobert avatar djoos avatar john-coleman avatar jujugrrr avatar katoga avatar maks3w avatar mcfedr avatar nathenharvey avatar nubs avatar odolbeau avatar pietervogelaar avatar predakanga avatar rjocoleman avatar trinitronx avatar tystr avatar winmillwill avatar yuya-takeyama avatar zuazo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

composer's Issues

Cache folder problem

It's very very very very bad idea to store important files in cache directory.
Cache directories can easily be cleaned.
Is this any reason why you not store file at "install_dir"?

Wrong owner and group of cache files

In the same manner as in #37, when using vagrant and setting the composer_home to /home/vagrant/.composer, the cache files themselves (see the contents of /home/vagrant/.composer/cache) are created by root, meaning that if you once ran vagrant provision, you can't run composer update or install from inside the machine (sshing into the vagrant machine and running it from there) as a permissions issue will prevent you from updating the cache files.

Skipping the php package for an already installed php version

Using it with AWS OpsWorks I have specified and installed php 5.5 on the machine already but when composer (this cookbook) requires php it tries to install an older version of php, error below:

Berksfile

source "https://supermarket.chef.io"

cookbook 'composer', '~> 2.2.0'

Log

[2015-09-12T12:10:18+00:00] INFO: ruby_block[Check that the ECS agent is running] called
[2015-09-12T12:10:18+00:00] INFO: Processing package[php] action install (php::package line 59)
[2015-09-12T12:10:18+00:00] INFO: package[php] installing php-5.3.29-1.8.amzn1 from amzn-updates repository

================================================================================
Error executing action `install` on resource 'package[php]'
================================================================================


Chef::Exceptions::Exec
----------------------
returned 1, expected 0


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/php/recipes/package.rb

59:     package pkg do
60:       action :install
61:       options node['php']['package_options']
62:     end
63:   end



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/php/recipes/package.rb:59:in `block in from_file'

package("php") do
action [:install]
retries 0
retry_delay 2
package_name "php"
version "5.3.29-1.8.amzn1"
cookbook_name "php"
recipe_name "package"
end



[2015-09-12T12:10:21+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-09-12T12:10:21+00:00] ERROR: Running exception handlers
[2015-09-12T12:10:21+00:00] ERROR: Exception handlers complete
[2015-09-12T12:10:21+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2015-09-12T12:10:22+00:00] ERROR: package[php] (php::package line 59) had an error: Chef::Exceptions::Exec:  returned 1, expected 0
[2015-09-12T12:10:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Documented examples don't work

Hi all,

Not sure if it's a documentation issue or a code issue, but I thought I should let you guys know about it.
true and false are not acceptable values as documented in the examples, one must use TrueClass or FalseClass.

Chef::Exceptions::ValidationFailed
----------------------------------
Option dev must be equal to one of: TrueClass, FalseClass!  You passed true.

Keep up the good work.
Cheers

Error executing action `start` on resource 'service[haproxy]'

Running RHEL6.2
Haproxy will not start: I have installed redhat-lsb but this did not fix the issue. Any suggestions would be greatly appreciated.

Thanks

Error Below

Mixlib::ShellOut::ShellCommandFailed

Expected process to exit with [0], but received '2'
---- Begin output of /sbin/service haproxy start ----
STDOUT:
STDERR: /etc/init.d/haproxy: line 84: log_daemon_msg: command not found
/etc/init.d/haproxy: line 38: start-stop-daemon: command not found
/etc/init.d/haproxy: line 96: log_end_msg: command not found
---- End output of /sbin/service haproxy start ----
Ran /sbin/service haproxy start returned 2

Resource Declaration:

In /var/chef/cache/cookbooks/haproxy/recipes/default.rb

106: service "haproxy" do
107: supports :restart => true, :status => true, :reload => true
108: action [:enable, :start]
109: end

Compiled Resource:

Declared in /var/chef/cache/cookbooks/haproxy/recipes/default.rb:106:in `from_file'

service("haproxy") do
action [:enable, :start]
updated true
supports {:restart=>true, :status=>true, :reload=>true}
retries 0
retry_delay 2
service_name "haproxy"
enabled true
pattern "haproxy"
cookbook_name "haproxy"
recipe_name "default"
end

Running handlers:
[2014-03-25T15:26:30-05:00] ERROR: Running exception handlers
Running handlers complete

[2014-03-25T15:26:30-05:00] ERROR: Exception handlers complete
[2014-03-25T15:26:30-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 2 resources updated in 20.478631963 seconds
[2014-03-25T15:26:31-05:00] ERROR: service[haproxy](haproxy::default line 106) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of /sbin/service haproxy start ----
STDOUT:
STDERR: /etc/init.d/haproxy: line 84: log_daemon_msg: command not found
/etc/init.d/haproxy: line 38: start-stop-daemon: command not found
/etc/init.d/haproxy: line 96: log_end_msg: command not found
---- End output of /sbin/service haproxy start ----
Ran /sbin/service haproxy start returned 2
[2014-03-25T15:26:31-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Undefined local variable or method `use_inline_resources'

I tried to use this cookbook with Vagrant (1.4.2) having Ubuntu 12.04 as a guest. But I got this error:

Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/composer/provi
ders/project.rb

NameError
---------
undefined local variable or method `use_inline_resources' for #<Class:0x7f19a963
d9a8>

Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/composer/providers/project.rb:8:in `
class_from_file'

Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/composer/providers/project.rb:

  1:  #
  2:  # Cookbook Name:: composer
  3:  # Resource:: project
  4:  #
  5:  # Copyright 2012-2013, Escape Studios
  6:  #
  7:
  8:  use_inline_resources
  9:

I believe it's because Vagrant installs Chef 10.14.2 by default (or it depends on guest system) and the cookbook uses feature from Chef 11+.

So it's not a real problem to install the latest version of Chef. But maybe you should mention that in requirements or do some backwards compatibility checks.

P.S: sorry for my English.

Composer installs unstable version

With the default attribute:

default['composer']['url'] = 'http://getcomposer.org/composer.phar'

It's downloading the 2.0-dev version of composer:

axel@ryzen:/tmp$ curl -s http://getcomposer.org/composer.phar -o composer.phar
axel@ryzen:/tmp$ php composer.phar --version
Composer version 2.0-dev (2.0-dev+8b0da77a1d5173f65b026d7475a1526bc29df939) 2020-04-09 08:48:48

I think having an unstable version of composer by default should not be the default behavior, so I suggest the attribute to be changed to:

default['composer']['url'] = 'https://getcomposer.org/composer-stable.phar

"no implicit conversion of nil into Hash" error introduced in recent update

Hi there folks πŸ‘‹

Firstly thanks for the cookbook, we've been using it for a while now and it's been working a treat πŸŽ‰

We have recently hit into an error no implicit conversion of nil into Hash which I think I've tracked down to a recent commit/release. This is the commit that introduced the error: dce62a6

And here is my trace:

             TypeError
             ---------
             no implicit conversion of nil into Hash
             
             Cookbook Trace:
             ---------------
             /tmp/kitchen/cache/cookbooks/composer/providers/project.rb:51:in `merge'
             /tmp/kitchen/cache/cookbooks/composer/providers/project.rb:51:in `block in make_execute'
             /tmp/kitchen/cache/cookbooks/composer/providers/project.rb:48:in `make_execute'
             /tmp/kitchen/cache/cookbooks/composer/providers/project.rb:15:in `block in class_from_file'

The problem is on this line: dce62a6#diff-56b028966c4e078e89abd54cb2714a2bR51 where we are merging your internal environment hash with the resource's defined environment hash, but in my case we don't have any environment defined.

Here is how we were using the resource: (note it is being triggered by another resource hence the action :nothing )

    composer_project "#{git_repo_folder}" do
        only_if { composer }
        action :nothing
    end

We have had to change it to the following to get it to work:

    composer_project "#{git_repo_folder}" do
        only_if { composer }
        action :nothing
        environment Hash.new
    end

My suggestion for a fix would be to amend this line dce62a6#diff-c094c2b89a0693295a9ac3a239f2ab45R24 to attribute :environment, :kind_of => Hash, :default => Hash.new if that is valid syntax, or for you to protect the merge lines so that they can handle being passed nil πŸ‘

Recipe Compile Error in /var/chef/cache/cookbooks/haproxy/providers/lb.rb

I have 4 Red Hat Enterprise Linux Servers version 6.2
Goal:
1 server to be chef server (version 10.24.0 )
1 server to be haproxy server ( version 1.6.2 )
1 server to be apache tomcat (version latest)
1 server to be apache tomcat (version latest)

Recipe Compile Error in /var/chef/cache/cookbooks/haproxy/providers/lb.rb

NameError

undefined local variable or method `use_inline_resources' for #Class:0x0000000226c288

Cookbook Trace:

/var/chef/cache/cookbooks/haproxy/providers/lb.rb:1:in `class_from_file'

Relevant File Content:

/var/chef/cache/cookbooks/haproxy/providers/lb.rb:

1>> use_inline_resources
2:
3: action :create do
4: #While there is no way to have an include directive for haproxy
5: #configuration file, this provider will only modify attributes !
6: listener = []
7: listener << "bind #{new_resource.bind}" unless new_resource.bind.nil?
8: listener << "balance #{new_resource.balance}" unless new_resource.balance.nil?
9: listener << "mode #{new_resource.mode}" unless new_resource.mode.nil?
10: listener += new_resource.servers.map {|server| "server #{server}" }

[2014-03-21T12:11:37-05:00] ERROR: Running exception handlers
[2014-03-21T12:11:37-05:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2014-03-21T12:11:37-05:00] ERROR: Exception handlers complete
[2014-03-21T12:11:37-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-03-21T12:11:37-05:00] FATAL: NameError: undefined local variable or method `use_inline_resources' for #Class:0x0000000226c288

composer_project skipping due to "only_if"

Hi guys! I need a bit of help. I'm obviously using the cookbook wrong, but I can't figure out why.

Got the following recipe:

include_recipe 'composer'

composer_project '/www/satis' do
  vendor 'composer/satis'
  path '/www/satis'
  dev true
  quiet false
  action [:require, :install]
end

Which I would think installs composer and deploys "satis" to my machine. However, when my recipe runs, I get the following output for "composer_project":

* composer_project[/www/satis] action require
           * execute[Install-composer-for-single-project] action run (skipped due to only_if)
         * composer_project[/www/satis] action install
           * execute[install-composer-for-project] action run (skipped due to only_if)

Composer installs but satis is not deployed. What is the proper way of doing what I'm trying to do?

Thanks in advance!

Setup config per user use the same global COMPOSER_HOME

Actual implementation of COMPOSER_HOME is not per user aware.

Create composer_home is not synced with env var and is not per user aware.

  configs.each_pair do |user, user_configs|
  directory "/home/#{user}/.composer" do
      owner user
      group user
      mode 0755
      action :create
    end

  # but later

  environment 'COMPOSER_HOME' => Composer.home_dir(node)

So Composer.home_dir(node) is global and does not match with /home/#{user}/.composer

COMPOSER_HOME should end with ".composer" dir

For the "global config thing" to work we have to make sure that we add '.composer' to the home_dir attribute.

But, you could do that on recipe side. Something like:

  def self.home_dir(node)
    node['composer']['home_dir']+'/.composer' || install_dir(node)
  end

Is how it is done by other cookbooks. See vagrant-cookbook
But I don't mind if you just update documentation for others to be aware. ;)

issue with attributes: node['composer']['global_configs']

I was setting like this:

    chef.json = {
      :composer => {
        "global_configs"  => {
          "vagrant"=>{
            "repositories"=> [
              { "packagist"=> false },
              {
                "type"=> "composer",
                "url"=> "http://218.244.132.204/proxy/packagist"
              }
            ]
          }
        } 
      }
}

but seems like It's not right, I got this error during provision:

==> my-project: Mixlib::ShellOut::ShellCommandFailed
==> my-project: ------------------------------------
==> my-project: Expected process to exit with [0], but received '2'
==> my-project: ---- Begin output of composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] ----
==> my-project: STDOUT:
==> my-project: STDERR: sh: 1: cannot create false},: Permission denied
==> my-project: ---- End output of composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] ----
==> my-project: Ran composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] returned 2
==> my-project:
==> my-project:
==> my-project: Resource Declaration:
==> my-project: ---------------------
==> my-project: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/composer/recipes/global_configs.rb
==> my-project:
==> my-project:  33:         execute "composer-config-for-#{user}" do
==> my-project:  34:           command "composer config --global #{option} #{value}"
==> my-project:
==> my-project:  35:           environment 'COMPOSER_HOME' => node['composer']['install_dir']
==> my-project:  36:           user user
==> my-project:  37:           group user
==> my-project:  38:           action :run
==> my-project:  39:         end
==> my-project:  40:       end
==> my-project:
==> my-project: Compiled Resource:
==> my-project: ------------------
==> my-project: # Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/composer/recipes/global_configs.rb:33:in `block (2 levels) in from_file'
==> my-project:
==> my-project: execute("composer-config-for-vagrant") do
==> my-project:
==> my-project:   action [:run]
==> my-project:   retries 0
==> my-project:   retry_delay 2
==> my-project:   guard_interpreter :default
==> my-project:   command "composer config --global repositories [{\"packagist\"=>false}, {\"type\"=>\"composer\", \"url\"=>\"http://218.244.132.204/proxy/packagist\"}]"
==> my-project:   backup 5
==> my-project:   environment {"COMPOSER_HOME"=>"/usr/local/bin"}
==> my-project:   group "vagrant"
==> my-project:   returns 0
==> my-project:   user "vagrant"
==> my-project:   cookbook_name :composer
==> my-project:   recipe_name "global_configs"
==> my-project: end
==> my-project:
==> my-project:
==> my-project:
==> my-project: [2014-10-15T03:26:41+00:00] INFO: Running queued delayed notifications before re-raising exception
==> my-project: [2014-10-15T03:26:41+00:00] ERROR: Running exception handlers
==> my-project: [2014-10-15T03:26:41+00:00] ERROR: Exception handlers complete
==> my-project: [2014-10-15T03:26:41+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> my-project: [2014-10-15T03:26:41+00:00] ERROR: execute[composer-config-for-vagrant] (composer::global_configs line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
==> my-project: ---- Begin output of composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] ----
==> my-project: STDOUT:
==> my-project: STDERR: sh: 1: cannot create false},: Permission denied
==> my-project: ---- End output of composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] ----
==> my-project: Ran composer config --global repositories [{"packagist"=>false}, {"type"=>"composer", "url"=>"http://218.244.132.204/proxy/packagist"}] returned 2
==> my-project: [2014-10-15T03:26:41+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

could anyone tell me It's my fault or there's something wrong on this cookbook?

global_configs - Delay evaluation until converge phase

Hi there! Thanks for this cookbook.

I ran into a fun issue due to the delightful multi-phase execution model of chef figured I'd report it. I did find a workaround, but it's just slightly ugly.

The root issue is this spot in the global_configs recipe which is troublesome with a custom user: https://github.com/djoos-cookbooks/composer/blob/master/recipes/global_configs.rb#L12

When node['composer']['global_configs'] contains a user that does not yet exist, but will be created during the chef recipe, then composer::global_configs will fail with something like this beautiful message:

       ================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/bethel_packaging/recipes/default.rb
       ================================================================================

       ArgumentError
       -------------
       user satis doesn't exist

       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/composer/recipes/global_configs.rb:12:in `home'
         /tmp/kitchen/cache/cookbooks/composer/recipes/global_configs.rb:12:in `block in from_file'
         /tmp/kitchen/cache/cookbooks/composer/recipes/global_configs.rb:11:in `each_pair'
         /tmp/kitchen/cache/cookbooks/composer/recipes/global_configs.rb:11:in `from_file'
         /tmp/kitchen/cache/cookbooks/composer/recipes/default.rb:11:in `from_file'
         /tmp/kitchen/cache/cookbooks/bethel_packaging/recipes/satis.rb:16:in `from_file'
         /tmp/kitchen/cache/cookbooks/bethel_packaging/recipes/default.rb:9:in `from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/composer/recipes/global_configs.rb:

         5:  # Copyright (c) 2016, David Joos
         6:  #
         7:
         8:  configs = node['composer']['global_configs']
         9:
        10:  unless configs.nil?
        11:    configs.each_pair do |user, user_configs|
        12>>     user_composer_dir = "#{Dir.home(user)}/.composer"
        13:
        14:      directory user_composer_dir do
        15:        owner user
        16:        group user
        17:        mode 0755
        18:        action :create
        19:      end
        20:
        21:      user_configs.nil? && next

       Platform:
       ---------
       x86_64-linux

yuck ^

The workaround is to make your user resource (wherever it is) run during the compile phase and it looks like this:

user satis_user do
  comment 'local user for satis'
  manage_home true
  action :nothing
end.run_action(:create)

With that little method tagged onto the end of the resource it worked as intended I think. So it may be useful to do one of:

  1. Make a note in the README of this behavior
  2. Rework global_configs in some way to use a lazy eval style so it only runs during the converge phase

Hope this info is helpful in some way.

sudo command on debian root user not available

If you execute the default recipe on a debian 7 system with the root user, the recipe failed due to the hardcoded sudo command:

[2013-12-27T19:03:03+01:00] INFO: Processing bash[download_composer] action run (composer::default line 23)
[2013-12-27T19:03:04+01:00] INFO: bash[download_composer] ran successfully
[2013-12-27T19:03:04+01:00] INFO: Processing bash[move_composer] action run (composer::default line 32)
[2013-12-27T19:03:05+01:00] INFO: Running queued delayed notifications before re-raising exception
[2013-12-27T19:03:05+01:00] ERROR: Running exception handlers
[2013-12-27T19:03:05+01:00] ERROR: Exception handlers complete
[2013-12-27T19:03:05+01:00] FATAL: Stacktrace dumped to /root/chef/chef-stacktrace.out
[2013-12-27T19:03:05+01:00] ERROR: bash[move_composer] (composer::default line 32) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '127'
---- Begin output of "bash"  "/tmp/chef-script20131227-29568-1fwogft" ----
STDOUT: 
STDERR: /tmp/chef-script20131227-29568-1fwogft: line 1: sudo: command not found
---- End output of "bash"  "/tmp/chef-script20131227-29568-1fwogft" ----
Ran "bash"  "/tmp/chef-script20131227-29568-1fwogft" returned 127

================================================================================
Error executing action `run` on resource 'bash[move_composer]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '127'
---- Begin output of "bash"  "/tmp/chef-script20131227-29568-1fwogft" ----
STDOUT: 
STDERR: /tmp/chef-script20131227-29568-1fwogft: line 1: sudo: command not found
---- End output of "bash"  "/tmp/chef-script20131227-29568-1fwogft" ----
Ran "bash"  "/tmp/chef-script20131227-29568-1fwogft" returned 127


Resource Declaration:
---------------------
# In /root/chef/cookbooks/composer/recipes/default.rb

 32:    bash "move_composer" do
 33:        cwd "#{Chef::Config[:file_cache_path]}"
 34:        code <<-EOH
 35:            sudo mv composer.phar #{node[:composer][:prefix]}/bin/composer
 36:        EOH
 37:        not_if "which composer"
 38:    end
 39: end


Compiled Resource:
------------------
# Declared in /root/chef/cookbooks/composer/recipes/default.rb:32:in `from_file'

bash("move_composer") do
  action "run"
  retries 0
  retry_delay 2
  command "\"bash\"  \"/tmp/chef-script20131227-29568-1fwogft\""
  backup 5
  cwd "/root/chef"
  returns 0
  code "\t\t\tsudo mv composer.phar /usr/local/bin/composer\n"
  interpreter "bash"
  cookbook_name :composer
  recipe_name "default"
  not_if "which composer"
end



[2013-12-27T19:01:05+01:00] INFO: Forking chef instance to converge...
[2013-12-27T19:03:05+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

This only occur if you execute chef / chef-solo with root user on this system.
A fast fix is to remove the sudo command. But this is not a good solution.
A better way is to check if the root user was used.

ERROR: undefined method '[]' for nillClass

Hi,
I had done install php 5.3 in centos 6.5 server.
I use the last cookbook ver: 2.0.0
I all ready: include_recipe "composer" in my cookbook
it allway show : ==> default: 8>> include_recipe node['composer']['php_recipe']
with: ==> default: [2015-01-30T02:54:09+00:00] ERROR: undefined method `[]' for nil:NilClass

I had read #37 but not help.
Please help me understand why.
Thankful.

Track changes between releases

You should provide a way for see the release notes of each release.

You may use a CHANGELOG file and or GitHub's release process or wiki pages.

Add a provider to install a global requirement

E.g. phpcs, phpcpd.
Now each of these repositories has the same code, the same template, ...
What I'd propose is a provider which uses the composer_project provider in the background with :require as action, so the composer.json file in a folder is manipulated instead of begin remade. It would also create a symlink from the global install dir (e.g. /usr/local/bin), which would be an attribute in this cookbook.

The advantages are:

  • all composer stuff could easily be installed in e.g. /usr/local. If you want to install specific items somewhere else, it can easily be adapted.
  • No more replication of code across cookbooks

The provider would e.g. be
composer_install_global 'install_dir' do
package 'package_name'
version 'version'
path 'path'
end

What do you think? I'll start working on a PR for this later.

Separate install_dir from COMPOSER_HOME

Case in point:
I'm running vagrant with an ubuntu guest.
If I'm not supplying any install_dir, it defaults to /usr/local/bin, which is a root user/group directory.
This means, the config and auth files will also be saved in /usr/local/bin as providers/project.rb treats the install_dir as COMPOSER_HOME.

So.. when you try to set any global config parameter, it tries to create the config.json file in /usr/local/bin, with the provided user (composer['global_config']['userX']...), which is not root.
This action of course fails.

allow for setting --no-plugins

composer install allows for the --no-plugins setting, it would be great if it was possible to set that in a composer_project block. Currently I have to resort to calling composer install --no-plugins via shellout.

Fatal error: Allowed memory size of 1073741824 bytes exhausted

Hi,

When running composer_project update on a project its running out of memory, see the extract below. Is there a parameter I can pass which ups the default memory allocation?

οΏ½[0m* composer_project[/u/current] action update

  • execute[update-composer-for-project] action run
    οΏ½[0m
    ================================================================================οΏ½[0m
    οΏ½[31mError executing action run on resource 'execute[update-composer-for-project]'οΏ½[0m
    ================================================================================οΏ½[0m

οΏ½[0m Mixlib::ShellOut::ShellCommandFailedοΏ½[0m
------------------------------------οΏ½[0m
Expected process to exit with [0], but received '255'
οΏ½[0m ---- Begin output of /usr/local/bin/composer update --no-interaction --no-ansi --no-dev ----
οΏ½[0m STDOUT: Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 72 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Decisions.php on line 40

Support global config

Composer has global configuration feature.

By default, composer load config file $HOME/.composr/config.json.
Scheme of config.json is described here: http://getcomposer.org/doc/04-schema.md#config

Detail of where to place config.json: http://getcomposer.org/doc/03-cli.md#composer-home

I suggest below:

  • Add global_configs and global_config attribute.
  • global_config is configuration for root (or user who execute chef).
  • global_configs is a hash of which key is username and value is configuration
  • recipe[composer] installs config.json using global_config when install_globally is false.
  • recipe[composer] installs config.json using global_configs when install_globally is true.

composer fail on update

I get the following error when a chef-client run automatically:

#<Mixlib::ShellOut::ShellCommandFailed: execute[composer-self_update] (composer::self_update line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' ---- Begin output of composer self-update ---- STDOUT: STDERR: [RuntimeException] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly self-update [-r|--rollback] [--clean-backups] [version] ---- End output of composer self-update ---- Ran composer self-update returned 1> had an error:
execute[composer-self_update] (composer::self_update line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' ---- Begin output of composer self-update ---- STDOUT: STDERR: [RuntimeException] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly self-update [-r|--rollback] [--clean-backups] [version] ---- End output of composer self-update ---- Ran composer self-update returned 1

Using symlinks instead of copying

Using symlink to chef cache is very bad idea.
Cache folder may be incompatible with the right to execute the file.

For example, I use chef-solo and run it from /root/chef folder.

Also, Acache folder becomes very important in the server. You have lost the ability to simply clear it.

Artifact v2.5.1 from Supermarket is invalid

Hi! Thanks for the cookbook. It looks really cool!

But I've noticed that the composer cookbook artifact v2.5.1 from supermarket.chef.io has a lot of redundant content which makes it invalid. That's probably caused by removing chefignore in ae2d100

How to reproduce:

  1. Create Policyfile.rb:
name 'test-composer'
default_source :supermarket
run_list 'composer'
cookbook 'composer', '= 2.5.1'
  1. Download the cookbook by running:
$ chef install Policyfile.rb
  1. Look at the content of the cookbook cache:
$ tree ~/.chefdk/cache/cookbooks/composer-2.5.1-supermarket.chef.io
β”œβ”€β”€ Berksfile
β”œβ”€β”€ Berksfile.lock
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ PaxHeader
β”‚Β Β  β”œβ”€β”€ Berksfile
β”‚Β Β  β”œβ”€β”€ Berksfile.lock
β”‚Β Β  β”œβ”€β”€ CONTRIBUTING.md
β”‚Β Β  β”œβ”€β”€ README.md
β”‚Β Β  β”œβ”€β”€ Rakefile
β”‚Β Β  β”œβ”€β”€ TESTING.md
β”‚Β Β  β”œβ”€β”€ attributes
β”‚Β Β  β”œβ”€β”€ libraries
β”‚Β Β  β”œβ”€β”€ metadata.json
β”‚Β Β  β”œβ”€β”€ metadata.rb
β”‚Β Β  β”œβ”€β”€ providers
β”‚Β Β  β”œβ”€β”€ recipes
β”‚Β Β  └── resources
β”œβ”€β”€ README.md
β”œβ”€β”€ Rakefile
β”œβ”€β”€ TESTING.md
β”œβ”€β”€ attributes
β”‚Β Β  β”œβ”€β”€ PaxHeader
β”‚Β Β  β”‚Β Β  └── default.rb
β”‚Β Β  └── default.rb
β”œβ”€β”€ libraries
β”‚Β Β  β”œβ”€β”€ PaxHeader
β”‚Β Β  β”‚Β Β  └── composer.rb
β”‚Β Β  └── composer.rb
β”œβ”€β”€ metadata.json
β”œβ”€β”€ metadata.rb
β”œβ”€β”€ providers
β”‚Β Β  β”œβ”€β”€ PaxHeader
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ install_global.rb
β”‚Β Β  β”‚Β Β  └── project.rb
β”‚Β Β  β”œβ”€β”€ install_global.rb
β”‚Β Β  └── project.rb
β”œβ”€β”€ recipes
β”‚Β Β  β”œβ”€β”€ PaxHeader
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ default.rb
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ global_configs.rb
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ install.rb
β”‚Β Β  β”‚Β Β  └── self_update.rb
β”‚Β Β  β”œβ”€β”€ default.rb
β”‚Β Β  β”œβ”€β”€ global_configs.rb
β”‚Β Β  β”œβ”€β”€ install.rb
β”‚Β Β  └── self_update.rb
└── resources
    β”œβ”€β”€ PaxHeader
    β”‚Β Β  β”œβ”€β”€ install_global.rb
    β”‚Β Β  └── project.rb
    β”œβ”€β”€ install_global.rb
    └── project.rb

11 directories, 41 files

There are PaxHeader folder created in each subfolder with the content duplicating the content of its base dir. This makes the cookbook invalid and causes failures of Chef Client run on Recipe Compile step.

If we would use berks & Berksfile instead of chef & Policyfile.rb, then there will be the similar result in cache except the fact that all PaxHeader folders will be empty.

Just to compare - here is the content of v2.5.0 artifact, which is valid and works fine:

$ tree ~/.chefdk/cache/cookbooks/composer-2.5.0-supermarket.chef.io
β”œβ”€β”€ README.md
β”œβ”€β”€ attributes
β”‚Β Β  └── default.rb
β”œβ”€β”€ libraries
β”‚Β Β  └── composer.rb
β”œβ”€β”€ metadata.json
β”œβ”€β”€ metadata.rb
β”œβ”€β”€ providers
β”‚Β Β  β”œβ”€β”€ install_global.rb
β”‚Β Β  └── project.rb
β”œβ”€β”€ recipes
β”‚Β Β  β”œβ”€β”€ default.rb
β”‚Β Β  β”œβ”€β”€ global_configs.rb
β”‚Β Β  β”œβ”€β”€ install.rb
β”‚Β Β  └── self_update.rb
└── resources
    β”œβ”€β”€ install_global.rb
    └── project.rb

5 directories, 13 files

Suggested solution:

Roll-back chefignore file and re-upload the artifact to the supermarket.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.