Rswag: Authorization header appeared in query parameter - header

Version: rswag (2.0.5), rspec (3.8.0)
Environment: Rails 5.2.3, Ruby 2.4.5
It is my first time to use it, was stuck in authorization header for a day.
Here is what I did:
# in spec/swagger_helper.rb
config.swagger_docs = {
'api/v1/swagger.json' => {
swagger: '2.0',
info: {
title: 'API V1',
version: 'v1'
},
paths: {},
securityDefinitions: {
JWT: {
description: 'the jwt for API auth',
type: :apiKey,
name: 'Authorization',
in: :header
}
}
}
}
# in spec/integration/api/v1/nodes_spec.rb
path '/api/v1/nodes' do
get 'Get all servers' do
tags TAGS_NODE
produces 'application/json'
security [JWT: {}]
parameter name: :searchString, in: :query, type: :string
parameter name: :searchColumn, in: :query, type: :string
#parameter name: 'Authorization', :in => :header, :type => :string
let(:nodes) { create_list(:node_list, 32) }
response '200', 'Servers found' do
let(:'Authorization') { "Bearer #{gen_jwt}" }
let(:searchString) { 'test' }
let(:searchColumn) { ';Name;' }
run_test! do |repsonse|
data = JSON.parse(response.body)
puts data
end
end
end
end
Expected: The 'Bearer ....' is set in 'Authorization' header
Actual: In the test log, I found:
[INFO] [2019-09-29 01:11:13 UTC] [anony] [no session] [no req] [other other]Started GET "/api/v1/nodes?searchString=test&searchColumn=;Name;&params&headers[HTTP_AUTHORIZATION]=Bearer+eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1Njk3NjI2NzMsImVtYWlsIjoidGVzdEBpYm0uY29tIiwib3JnYW5pemF0aW9ucyI6WyJ0ZXN0X29yZzEiLCJvcmcyIl0sInJvbGVzIjpbImNjX2NvbnNvbGVfYWRtaW4iLCJyb2xlMiJdLCJpbnZlbnRvcnkiOlsidGVzdF9pbnYiXX0.eenTMWUy6kSHO58_kLKoKWmNjvQ9i5TU9ex4Ou-ausE&headers[HTTP_ACCEPT]=application%2Fjson" for 127.0.0.1 at 2019-09-29 01:11:13 +0000
[INFO] [2019-09-29 01:11:13 UTC] [anony] [no session] [no req] [other other]Processing by Api::V1::NodesController#index as HTML
......
[DEBUG] [2019-09-29 01:11:13 UTC] [anony] [no session] [no req] [other other]Auth by JWT token....
[ERROR] [2019-09-29 01:11:13 UTC] [anony] [no session] [no req] [other other]No JWT token included in request
As marked as bold in the log, the 'Authorization' as well as 'Accept' headers are appeared in query parameters, which are supposed to be http headers, so that no JWT token can be retrieved from header in code.
I also tried not to use securityDefinition, but specify a parameter in header as following: parameter name: 'Authorization', :in => :header, :type => :string. It did not work either.
Not sure any configuration I missed, or something wrong I did? Thanks!
Update: it seems to be related to other gems conflict? I had another try to create a new Rails 5 api only app, add rspec and rswag gems only, and run with a simple test case, it worked!
Here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.4.5'
gem 'rails', '5.2.3'
gem 'puma', '3.11'
gem 'bootsnap', '1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
end
group :test do
# Test framework
gem "rspec-rails"
gem "database_cleaner", '1.6.0'
gem "simplecov"
gem "simplecov-rcov"
gem "factory_bot_rails", '5.1.0'
gem "ci_reporter_rspec"
gem "faker"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'pg', '1.1.4'
gem 'delayed_job_active_record', '4.1.3'
gem 'delayed_job_worker_pool', '0.2.3'
gem 'dalli', '2.7.8'
gem 'ruby-kafka', '0.7.5'
gem 'active_model_serializers', '0.10.10'
gem 'will_paginate', '3.1.7'
gem 'rest-client', '1.8.0'
gem 'symmetric-encryption', '4.3.0', require: false
gem 'unicorn', '5.2.0'
gem 'rubyzip', '1.2.2'
gem 'jwt', '2.2.1'
gem 'rubyXL', '3.3.30'
gem 'apartment', '2.2.1'
gem 'rswag', '2.0.5'
[Resolved]
Seems not working with Rack::Test::Methods
It worked after remove the line 'include Rack::Test::Methods" in a helper file, which was added previously to use 'get' to test the API.

Seems not working with Rack::Test::Methods
It worked after remove the line 'include Rack::Test::Methods" in a helper file, which was added previously to use 'get' to test the API.

Related

phoenix module ExAws.S3.Client is not loaded and could not be found

I use the library https://github.com/CargoSense/ex_aws, and I faced such problem:
== Compilation error on file web/models/s3.ex ==
** (CompileError) web/models/s3.ex:2: module ExAws.S3.Client is not loaded and could not be found
(elixir) expanding macro: Kernel.use/2
web/models/s3.ex:2: Minion.S3 (module)
(elixir) lib/kernel/parallel_compiler.ex:116: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
in my mix.exs:
def application do
[mod: {Minion, []},
applications: [:phoenix, ... :ex_aws, :httpoison, :poison]]
end
...
defp deps do
[{:phoenix, "~> 1.2.1"},
...
{:ex_aws, "~> 1.0.0-beta0"},
{:poison, "~> 2.0"},
{:httpoison, "~> 0.8"}]
end
my config.exs:
config :minion, :ex_aws,
access_key_id: "...",
secret_access_key: "...",
region: "us-east-1",
s3: [
scheme: "http://",
host: "...",
region: "us-east-1"
]
my s3.ex:
defmodule Minion.S3 do
use ExAws.S3.Client, otp_app: :minion
end
I will be grateful for any help to fix this problem
:ex_awsin version >= 1.0.0 does not use the old (pre 1.0.0) style where you needed to do as in your module Minion.S3. That's why ExAws.S3.Client does not exists. Instead, try:
Remove your file s3.ex
In config.exs, change from config :minion, :ex_aws, to config :ex_aws,
Update your requests to the new style: S3.list_buckets |> ExAws.request #=> {:ok, response} instead of old style Minion.S3.list_buckets

Phoenix/Elixir - Invalid Parameter error with Arc Ecto cast_attachments

I am trying to make an image upload function with Phoenix/elixir, and I am getting an error on the create action with my console giving me the following error message:
[debug] Processing by Callme.DoctorController.create/2
Parameters: %{"_csrf_token" => "AnpLGQsANzU1YmxQAwA8Oy4CA3VzAAAA45djZauss3TelOpHInPFFQ==", "_utf8" => "✓", "doctor" => %{"avatar" => %Plug.Upload{content_type: "image/jpeg", filename: "file000166349580.jpg", path: "C:\\Users\\Frank\\AppData\\Local\\Temp/plug-1470/multipart-62273-279000-1"}, "bio" => "m", "hiddeninfo" => "m", "name" => "m", "picture" => "m", "specialty" => "m"}}
Pipelines: [:browser]
[error] Task #PID<0.406.0> started from #PID<0.403.0> terminating
** (ArgumentError) argument error
(crypto) :crypto.sha256_mac_nif(["AWS4", nil], "20160801", 32)
(crypto) crypto.erl:1055: :crypto.sha256_mac/3
(ex_aws) lib/ex_aws/auth.ex:90: ExAws.Auth.signing_key/3
(ex_aws) lib/ex_aws/auth.ex:53: ExAws.Auth.signature/7
(ex_aws) lib/ex_aws/auth.ex:42: ExAws.Auth.auth_header/7
(ex_aws) lib/ex_aws/auth.ex:15: ExAws.Auth.headers/6
(ex_aws) lib/ex_aws/request.ex:31: ExAws.Request.request_and_retry/7
lib/arc/storage/s3.ex:14: Arc.Storage.S3.put/3
(elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:40: Task.Supervised.reply/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: #Function<2.133421496/0 in Arc.Actions.Store.async_put_version/3>
Args: []
[error] Task #PID<0.407.0> started from #PID<0.403.0> terminating
** (ArgumentError) argument error
(crypto) :crypto.sha256_mac_nif(["AWS4", nil], "20160801", 32)
(crypto) crypto.erl:1055: :crypto.sha256_mac/3
(ex_aws) lib/ex_aws/auth.ex:90: ExAws.Auth.signing_key/3
(ex_aws) lib/ex_aws/auth.ex:53: ExAws.Auth.signature/7
(ex_aws) lib/ex_aws/auth.ex:42: ExAws.Auth.auth_header/7
(ex_aws) lib/ex_aws/auth.ex:15: ExAws.Auth.headers/6
(ex_aws) lib/ex_aws/request.ex:31: ExAws.Request.request_and_retry/7
lib/arc/storage/s3.ex:14: Arc.Storage.S3.put/3
(elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:40: Task.Supervised.reply/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: #Function<2.133421496/0 in Arc.Actions.Store.async_put_version/3>
Args: []
[error] Ranch protocol #PID<0.403.0> (:cowboy_protocol) of listener Callme.Endpoint.HTTP terminated
** (exit) an exception was raised:
** (ArgumentError) argument error
(crypto) :crypto.sha256_mac_nif(["AWS4", nil], "20160801", 32)
(crypto) crypto.erl:1055: :crypto.sha256_mac/3
(ex_aws) lib/ex_aws/auth.ex:90: ExAws.Auth.signing_key/3
(ex_aws) lib/ex_aws/auth.ex:53: ExAws.Auth.signature/7
(ex_aws) lib/ex_aws/auth.ex:42: ExAws.Auth.auth_header/7
(ex_aws) lib/ex_aws/auth.ex:15: ExAws.Auth.headers/6
(ex_aws) lib/ex_aws/request.ex:31: ExAws.Request.request_and_retry/7
lib/arc/storage/s3.ex:14: Arc.Storage.S3.put/3
(elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:40: Task.Supervised.reply/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Here is the the create action:
def create(conn, %{"doctor" => doctor_params}) do
changeset = Doctor.changeset(%Doctor{}, doctor_params)
case Repo.insert(changeset) do
{:ok, _doctor} ->
conn
|> put_flash(:info, "Doctor created successfully.")
|> redirect(to: doctor_path(conn, :index))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
end
And here is my doctor.ex file:
defmodule Callme.Doctor do
use Callme.Web, :model
use Arc.Ecto.Model
schema "doctors" do
field :name, :string
field :hiddeninfo, :string
field :bio, :string
field :specialty, :string
field :picture, :string
field :avatar, Callme.Avatar.Type
has_many :services, Callme.Service
timestamps
end
#required_fields ~w(name hiddeninfo bio specialty picture )
#optional_fields ~w()
#required_file_fields ~w()
#optional_file_fields ~w(avatar)
#doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ :empty) do
model
|> cast(params, #required_fields, #optional_fields)
|> cast_attachments(params, #required_file_fields, #optional_file_fields)
end
end
Here is the Avatar.ex file:
defmodule Callme.Avatar do
use Arc.Definition
use Arc.Ecto.Definition
# Include ecto support (requires package arc_ecto installed):
# use Arc.Ecto.Definition
#versions [:original, :thumb]
#extension_whitelist ~w(.jpg .jpeg .gif .png)
def acl(:thumb, _), do: :public_read
def validate({file, _}) do
file_extension = file.file_name |> Path.extname |> String.downcase
Enum.member?(#extension_whitelist, file_extension)
end
def transform(:thumb, _) do
{ :noaction }
end
def filename(version, _) do
version
end
def storage_dir(_, {file, user}) do
"uploads/avatars/#{user.id}"
end
def default_url(:thumb) do
"https://placehold.it/100x100"
end
end
My mix file:
defmodule Callme.Mixfile do
use Mix.Project
def project do
[app: :callme,
version: "0.0.1",
elixir: "~> 1.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
aliases: aliases,
deps: deps]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[mod: {Callme, []},
applications: [:phoenix, :phoenix_html, :cowboy, :ex_aws, :httpoison, :logger, :gettext,
:phoenix_ecto, :postgrex]]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[{:phoenix, "~> 1.1.4"},
{:postgrex, ">= 0.0.0"},
{:ecto, "~>1.1.2", override: true},
{:phoenix_ecto, "~> 2.0"},
{:phoenix_html, "~> 2.4"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.9"},
{:comeonin, "~> 1.0"},
{:mailgun, "~> 0.1.2"},
{:poison, "~> 2.1", override: true},
{:cowboy, "~> 1.0"},
{:arc, "~> 0.5.2"},
{:ex_aws, "~> 0.4.10"},
{:arc_ecto, "~> 0.3.2"},
{:httpoison, "~> 0.7"}]
end
# Aliases are shortcut or tasks specific to the current project.
# For example, to create, migrate and run the seeds file at once:
# $ mix ecto.setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"]]
end
end
and my config file:
use Mix.Config
# Configures the endpoint
config :callme, Callme.Endpoint,
url: [host: "localhost"],
root: Path.dirname(__DIR__),
secret_key_base: "jTrdsYnbNCqUuRuBqUIg0p6YKgUG3paPiZgB0ivCF45uWfUhZAd/zxuOiOe0GVKe",
render_errors: [accepts: ~w(html json)],
pubsub: [name: Callme.PubSub,
adapter: Phoenix.PubSub.PG2]
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :arc,
bucket: "callme"
config :ex_aws,
access_key_id: System.get_env("AWS_ACCESS_KEY"),
secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY")
#.env library
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
import_config "config.secret.exs"
# Configure phoenix generators
config :phoenix, :generators,
migration: true,
binary_id: false
config :callme, Callme.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "callme_dev",
hostname: "localhost",
pool_size: 10
And also, here is a link to the github repository because I can't think of any other files that might have errors on them.
I hope we can figure this out. This has been literally an entire week now of trying to figure what is wrong with this thing and I feel like I am taking crazy pills.

vagrant provisining don't work on Windows but work on Ubuntu

I have vagrant/puppet provision script and see there is a problem when my host machine is Windows (when hosting on Ubuntu doesn't seems to have this problem). I can see that apache::concat working with apache ports.conf file have a problem. I'm using guest box same on both places (ubuntu server 14.04). As far as I know puppet is running on guest machine.
My question is why I have this warnings and errors during provisioning?
==> default: Running provisioner: puppet...
==> default: Running Puppet with default.pp...
==> default: stdin: is not a tty
==> default: Notice: Compiled catalog for eclectic.vm in environment production in 7.06 seconds
==> default: Notice: /Stage[main]/Main/Exec[apt-update]/returns: executed successfully
==> default: Notice: /Stage[main]/Main/Exec[git-checkout-drush]/returns: executed successfully
==> default: Notice: /Stage[main]/Main/File[/var/www/vhosts/eclectic.ca]/mode: mode changed '0777' to '0775'
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[/var/www/vhosts/eclectic.ca/public_html]/owner: owner changed 'www-data' to 'root'
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[/var/www/vhosts/eclectic.ca/public_html]/group: group changed 'vagrant' to 'root'
==> default: Error: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/Exec[concat_/etc/apache2/ports.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/File[/etc/apache2/ports.conf]: Dependency Exec[concat_/etc/apache2/ports.conf] has failures: true
==> default: Warning: /Stage[main]/Apache/Concat[/etc/apache2/ports.conf]/File[/etc/apache2/ports.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Exec[composer-install-drush]/returns: executed successfully
==> default: Error: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/Exec[concat_25-ssl-ca.eclectic.vm.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/File[25-ssl-ca.eclectic.vm.conf]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/Concat[25-ssl-ca.eclectic.vm.conf]/File[25-ssl-ca.eclectic.vm.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/File[25-ssl-ca.eclectic.vm.conf symlink]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ssl-ca.eclectic.vm]/File[25-ssl-ca.eclectic.vm.conf symlink]: Skipping because of failed dependencies
==> default: Error: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/Exec[concat_25-ca.eclectic.vm.conf]: Could not evaluate: /usr/bin/env: ruby
: No such file or directory
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/File[25-ca.eclectic.vm.conf]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/Concat[25-ca.eclectic.vm.conf]/File[25-ca.eclectic.vm.conf]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[25-ca.eclectic.vm.conf symlink]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Main/Apache::Vhost[ca.eclectic.vm]/File[25-ca.eclectic.vm.conf symlink]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_/etc/apache2/ports.conf] has failures: true
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_25-ca.eclectic.vm.conf] has failures: true
==> default: Notice: /Stage[main]/Apache::Service/Service[httpd]: Dependency Exec[concat_25-ssl-ca.eclectic.vm.conf] has failures: true
==> default: Warning: /Stage[main]/Apache::Service/Service[httpd]: Skipping because of failed dependencies
==> default: Notice: Finished catalog run in 18.24 seconds
My puppet file
# execute 'apt-get update'
exec { 'apt-update':
command => 'apt-get update',
path => ["/usr/bin"],
}
# Install and configure apache2
class { 'apache': # use the "apache" module
default_vhost => false, # don't use the default vhost
default_mods => false, # don't load default mods
mpm_module => 'prefork', # use the "prefork" mpm_module
service_ensure => 'running',
}
include apache::mod::php
include apache::mod::rewrite
# Enable not define apache mods
# https://forge.puppetlabs.com/puppetlabs/apache#defined-type-apachemod
apache::mod { 'access_compat': }
# http eclectic version
apache::vhost { 'com.domain.vm':
port => '80',
docadmin => '/var/www/vhosts/domain.com/public_html',
override => ['all'],
serveraliases => [
'www.com.domain.vm',
],
}
# https eclectic version
apache::vhost { 'ssl-com.domain.vm':
servername => 'com.domain.vm',
port => '443',
docadmin => '/var/www/vhosts/domain.com/public_html',
override => ['all'],
ssl => true,
serveraliases => [
'www.com.domain.vm',
],
}
# Setting up custom web eclectic direcotry
file { [
"/var/www",
"/var/www/vhosts",
"/var/www/vhosts/domain.com"
]:
ensure => "directory",
owner => "www-data",
group => "vagrant",
mode => 775,
}
# Add virtual host domain in /etc/hosts
host { 'com.domain.vm':
ensure => present,
ip => '127.0.0.1',
host_aliases => 'www.com.domain.vm',
}
# install mysql-server package
package { 'mysql-server':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure mysql service is running
service { 'mysql':
ensure => running,
require => Package['mysql-server'],
}
$packages = [
'vim',
'nano',
'htop',
'tree',
'pv',
'wget',
'curl',
'git',
'php5',
'php5-cli',
'php5-gd',
'php5-curl',
'php5-mysql',
'php5-mcrypt',
]
package { $packages:
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
exec { 'set-mysql-password':
command => 'mysqladmin -u admin password "admin"',
path => ["/usr/bin"],
logoutput => true,
unless => 'mysqladmin -uadmin -padmin version',
require => Service['mysql'],
}
package { 'php-pear':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
notify => [
Exec['pear-discover-channel-phing'],
Exec['pear-install-Console_Table'],
Exec['pear-install-Console_Color2'],
]
}
# http://puppet-php.readthedocs.org/en/latest/composer.html#installation
# Install to different destination
class { 'php::composer':
destination => '/usr/bin/composer',
notify => Exec['composer-install-drush']
}
exec { "pear-discover-channel-phing":
command => "pear channel-discover pear.phing.info",
path => ["/usr/bin"],
logoutput => true,
unless => 'pear channel-info pear.phing.info',
require => Package['php-pear'],
notify => Exec['pear-install-phing'],
}
exec { "pear-install-phing":
command => "pear install phing/phing",
unless => "which phing",
path => ["/usr/bin"],
logoutput => false,
require => Exec['pear-discover-channel-phing'],
}
exec { "pear-install-Console_Table":
command => "pear install Console_Table",
unless => "pear info Console_Table",
path => ["/usr/bin"],
logoutput => true,
}
exec { "pear-install-Console_Color2":
command => "pear install Console_Color2-0.1.2",
unless => "pear info Console_Color2-0.1.2",
path => ["/usr/bin"],
logoutput => true,
}
####################################
# Install drush
exec { "git-clone-drush":
command => "git clone https://github.com/drush-ops/drush.git /usr/local/src/drush",
path => ["/usr/bin"],
unless => 'test -d /usr/local/src/drush',
notify => Exec['git-checkout-drush']
}
exec { "git-checkout-drush":
command => "git checkout 6.6.0",
cwd => "/usr/local/src/drush",
path => ["/usr/bin"],
require => Exec['git-clone-drush'],
notify => File['/usr/bin/drush']
}
file { "/usr/bin/drush":
ensure => 'link',
target => '/usr/local/src/drush/drush',
require => Exec['git-checkout-drush'],
notify => Exec['composer-install-drush']
}
exec { "composer-install-drush":
environment => [ "COMPOSER_HOME=/usr/local/src/drush" ],
command => "composer install",
cwd => "/usr/local/src/drush",
path => ["/usr/bin"],
require => File['/usr/bin/drush']
}
# Copy ssh config vagrant file
file { '/home/vagrant/.ssh/config':
ensure => present,
mode => 600,
source => "puppet:///files/ssh/config/default-config",
}
Your problem is probably the same as mine, on which I spent the last couple of days. In my case the problem was with the windows git program.
When you install git under Windows it asks whether you would like to configure CRLF<->LF conversion - there are 3 options:
default, Checkout Windows-style, commit Unix-style line endings - that means convert LF to CRLF when checking out, and convert CRLF to LF when committing,
Checkout as-is, commit Unix-style line encodings - do not convert on check-out, and convert CRLF to LF when committing,
Checkout as-is, commit as-is - do not convert at all.
At first I chose (1), so git converted LF to CRLF when checking out one of the modules, icinga-vagrant\modules\concat, and specifically the script file icinga-vagrant\modules\concat\files\concatfragments.rb. The script then would be copied (without conversion) to the target Linux virtual machine, and wouldn't run there because /usr/bin/env didn't understand what "ruby<CR>" meant, and that's why the error message had a newline in it:
... Could not evaluate: /usr/bin/env: ruby
: No such file or directory
The resolution was to reinstall git with option nr (2), although it can probably be changed without reinstallation - I was a bit lazy. Now, git checks the script as is, with only LF at line ends, and so runs without problems on Linux.
Did you include module stdlib in puppet? concat is one of functions in it. Can you show me the Puppetfile if you manage forge module by librarian-puppet
Seems the dependence is the issue. Should fix your issue after install with it.

Running guard init duplicates watcher lines

I'm not sure how I've ended up here, but anytime I run guard init, it seems to go a bit overboard, and rather than adding coffeescript/sass/livereload once, it does each of them several times.
Here is what I get on the command line after running guard init:
WARN: Unresolved specs during Gem::Specification.reset:
thor (>= 0.14.6)
lumberjack (>= 1.0.2)
ffi (>= 0.5.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
11:39:55 - INFO - Writing new Guardfile to /var/www/the-newbies-guide-to-test-driven-development/Guardfile
11:39:55 - INFO - coffeescript guard added to Guardfile, feel free to edit it
11:39:55 - INFO - coffeescript guard added to Guardfile, feel free to edit it
11:39:55 - INFO - coffeescript guard added to Guardfile, feel free to edit it
11:39:57 - INFO - compass guard added to Guardfile, feel free to edit it
11:39:57 - INFO - concat guard added to Guardfile, feel free to edit it
11:39:58 - INFO - livereload guard added to Guardfile, feel free to edit it
11:39:58 - INFO - livereload guard added to Guardfile, feel free to edit it
11:39:58 - INFO - There are 2 definitions in your Guardfile for 'livereload', you may want to clean up your Guardfile as this could cause issues.
11:39:58 - INFO - livereload guard added to Guardfile, feel free to edit it
11:39:58 - INFO - There are 3 definitions in your Guardfile for 'livereload', you may want to clean up your Guardfile as this could cause issues.
11:39:58 - INFO - phpunit guard added to Guardfile, feel free to edit it
11:39:58 - INFO - sass guard added to Guardfile, feel free to edit it
11:39:58 - INFO - sass guard added to Guardfile, feel free to edit it
11:39:58 - INFO - sass guard added to Guardfile, feel free to edit it
11:39:58 - INFO - sass guard added to Guardfile, feel free to edit it
11:39:58 - INFO - sass guard added to Guardfile, feel free to edit it
11:39:58 - INFO - uglify guard added to Guardfile, feel free to edit it
With this being the contents of my Guardfile:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'coffeescript', :input => 'app/assets/javascripts'
guard 'coffeescript', :input => 'app/assets/javascripts'
guard 'coffeescript', :input => 'app/assets/javascripts'
guard 'compass' do
watch('^src/(.*)\.s[ac]ss')
end
# This will concatenate the javascript files specified in :files to public/js/all.js
guard :concat, type: "js", files: %w(), input_dir: "public/js", output: "public/js/all"
guard :concat, type: "css", files: %w(), input_dir: "public/css", output: "public/css/all"
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end
guard 'phpunit', :cli => '--colors' do
watch(%r{^.+Test\.php$})
end
guard 'sass', :input => 'sass', :output => 'css'
guard 'sass', :input => 'sass', :output => 'css'
guard 'sass', :input => 'sass', :output => 'css'
guard 'sass', :input => 'sass', :output => 'css'
guard 'sass', :input => 'sass', :output => 'css'
guard 'uglify', :destination_file => "public/javascripts/application.js" do
watch (%r{app/assets/javascripts/application.js})
end
Obviously I can just go in and remove the duplicated lines, but I was wondering why it happened in the first place.
It looks like guard will use all available versions of a plugin when running the init - not sure if it does this when actually running too (which would be worrying). I was having the same trouble and checked my gem list:
gem list | grep guard
This showed me how many versions of guard related plugins I had installed:
guard (1.8.2, 1.8.0, 1.7.0, 1.6.2, 1.6.1, 1.5.4, 1.0.3, 1.0.1)
guard-concat (0.0.3)
guard-rspec (3.0.0, 2.5.3, 2.4.1, 2.3.3, 2.1.2, 1.2.1, 0.7.2, 0.7.0)
guard-sass (1.3.2)
guard-spork (0.8.0)
guard-uglify (0.1.0)
terminal-notifier-guard (1.5.3)
Running gem cleanup on the guard plugin that gets repeated sorted it all out:
gem cleanup guard-rspec
gem list | grep guard
Which then showed:
guard (1.8.2, 1.8.0, 1.7.0, 1.6.2, 1.6.1, 1.5.4, 1.0.3, 1.0.1)
guard-concat (0.0.3)
guard-rspec (3.0.0)
guard-sass (1.3.2)
guard-spork (0.8.0)
guard-uglify (0.1.0)
terminal-notifier-guard (1.5.3)
When I run guard init now I do not have repeated code in my Guardfile.

nginx cannot load such file -- rubygems/path_support

I'm under nginx + passenger + rails 3.2.1 and when i try to start my app i get
cannot load such file -- rubygems/path_support
the output of gem environment is
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [i686-linux]
- INSTALLATION DIRECTORY: /root/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /root/.rbenv/versions/1.9.3-p327/bin/ruby
- EXECUTABLE DIRECTORY: /root/.rbenv/versions/1.9.3-p327/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /root/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
and in my nginx.conf i have
user root;
http {
passenger_root /root/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/passenger-3.0.19;
passenger_ruby /root/.rbenv/versions/1.9.3-p327/bin/ruby;
passenger_default_user root;
passenger_default_group root;
....
what else can i check?
Thank you
thanks a lot ! the code in your config file saved my life:
passenger_default_user root;
passenger_default_group root;
I met the same error with your and solved with your config file , the detailed answer is here: https://stackoverflow.com/a/15777738/445908