Ruby 2.5.3 to 2.6.0 leads to Policy already configured error - rspec-rails

When I update ruby 2.5.3 to 2.6.0 and try to run RSpec specs then it's throwing policy already configured error
The error stack as follows
An error occurred while loading ./spec/controllers/example_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)
SecureHeaders::Configuration::AlreadyConfiguredError:
Policy already configured
# /Users/codecpm/.rvm/gems/ruby-2.6.0/gems/secure_headers-6.1.1/lib/secure_headers/configuration.rb:19:in `default'
# ./config/initializers/secure_header.rb:1:in `<top (required)>'
But the server was running fine.
has anybody faced this issue before?

Related

Unplugin-vue-define-options TypeError

I want to mock a http request in Vue.js using Vitest. How can I perform testing for http requests
I use unplugin-vue-define-options LTS in my Vue.js 3 + Vite 3. After running my app, the following error is appeared.
[vite] Internal server error: unplugin-vue-define-options TypeError: Cannot read properties of undefined (reading 'scriptSetupAst')
I also reinstall the package, but there is still the above error.
I was having the same problem. But today I updated to the latest version released (1.1.3) and apparently this bug has been fixed.

Ruby App works with webrick but not with passenger

I'm trying to deploy a ruby app to a server running Ubuntu -> Nginx -> Passenger.
I can access the site fine using 'rails s' however passenger keeps returning the bellow error into the nginx log. I've checked that rake 12.0.0 is installed and also tried setting up a new rails project to check if passenger would provide the "your on rails" page. But that doesn't work either.
Any help would be greatly appreciated, I've tried googleing and performing various bundle updates and gem installs.
Error ID: a06f05a9
Error details saved to: /tmp/passenger-error-EVNeAF.html
Message from application: <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>
<pre class="commands">bundle install</pre>
<p>If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:</p>
<ol>
<li>Is this app supposed to be run as the <code>dmn</code> user?</li>
<li>Is this app being run on the correct Ruby interpreter? Below you will
see which Ruby interpreter Phusion Passenger attempted to use.</li>
<li>Please check whether the correct RVM gemset is being used.</li>
<li>Sometimes, RVM gemsets may be broken.
Try resetting them.</li>
</ol>
<p>-------- The exception is as follows: -------</p>
Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)
<pre> /home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/spec_set.rb:87:in `block in materialize'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/spec_set.rb:81:in `map!'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/spec_set.rb:81:in `materialize'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/definition.rb:159:in `specs'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/definition.rb:218:in `specs_for'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/definition.rb:207:in `requested_specs'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/runtime.rb:109:in `block in definition_method'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/runtime.rb:21:in `setup'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler.rb:101:in `setup'
/home/dmn/.rvm/gems/ruby-2.3.3/gems/bundler-1.15.4/lib/bundler/setup.rb:19:in `<top (required)>'
/home/dmn/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/dmn/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'</pre>"

Problems starting a freshly installed Mean Stack application

I'm trying to start a new mean stack application. However i only get this error when I'm running grunt to start the server:
[nodemon] v1.2.1
Running "watch" task
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
Waiting...
Debugger listening on port 5858
Mean app started on port 3000 (development) cluster.worker.id: 0
/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:246
throw message;
^
TypeError: Cannot read property 'length' of undefined
at processResults (/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1581:31)
at /Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1619:20
at /Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1157:7
at /Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1890:9
at Server.Base._callHandler (/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:448:41)
at /Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:481:18
at MongoReply.parseBody (/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:439:20)
at emit (events.js:107:17)
at null.<anonymous> (/Users/olehenrik/Sites/learn/mean_test2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
[nodemon] app crashed - waiting for file changes before starting...
Have any one encountered this before? Can't find too many other people who have encountered this before.
I was also facing the same error and this info solves it.
"Upgrade to 3.8.23. 3.8.22 introduced better compatibility with mongodb server 3.0 by upgrading to latest version of the driver." credit to vkarpov15 from mongoose Github thread.
What I did was I edit my package.json to upgrade mongoose to "3.8.23". After I edited the package.json I ran npm install and bower install(just to make sure) again and that solved the problem.

chef cookbook fails on ohai undefined method `[]' for nil:NilClass

I'm working on a chef cookbook to set up a vanilla ubuntu 12.04.2 with nginx postgresql and unicorn on my vagrant box, but I'm getting into troubles with nginx, there's an exception
undefined method `[]' for nil:NilClass
when installing it that seem to relate to ohai configuration.
I've posted all I have here:
https://github.com/DonGiulio/mychef
here's the output from chef-solo:
Starting Chef Client, version 11.4.0
Compiling Cookbooks...
================================================================================
Recipe Compile Error in /var/chef/cookbooks/nginx/recipes/source.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/var/chef/cookbooks/nginx/recipes/ohai_plugin.rb:27:in `from_file'
/var/chef/cookbooks/nginx/recipes/source.rb:42:in `from_file'
Relevant File Content:
----------------------
/var/chef/cookbooks/nginx/recipes/ohai_plugin.rb:
20: #
21:
22: ohai 'reload_nginx' do
23: plugin 'nginx'
24: action :nothing
25: end
26:
27>> template "#{node['ohai']['plugin_path']}/nginx.rb" do
28: source 'plugins/nginx.rb.erb'
29: owner 'root'
30: group 'root'
31: mode '0755'
32: notifies :reload, 'ohai[reload_nginx]', :immediately
33: end
34:
35: include_recipe 'ohai::default'
36:
[2013-11-19T14:22:23+00:00] ERROR: Running exception handlers
[2013-11-19T14:22:23+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-11-19T14:22:23+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-11-19T14:22:23+00:00] FATAL: NoMethodError: undefined method `[]' for nil:NilClass
and here's the stacktrace:
$ cat /var/chef/cache/chef-stacktrace.out
Generated at 2013-11-19 14:22:23 +0000
NoMethodError: undefined method `[]' for nil:NilClass
/var/chef/cookbooks/nginx/recipes/ohai_plugin.rb:27:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_version.rb:346:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:151:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:132:in `block in include_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:131:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:131:in `include_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
/var/chef/cookbooks/nginx/recipes/source.rb:42:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook_version.rb:346:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:151:in `load_recipe'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:139:in `block in compile_recipes'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:137:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context/cookbook_compiler.rb:74:in `compile'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/run_context.rb:86:in `load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:224:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:467:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:239:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:23:in `load'
/usr/bin/chef-solo:23:in `<main>'
UPDATE 1
I'm provisioning the box with ruby-2.0.0-p247, is there a dependency on an earlier version of ruby maybe?
UPDATE 2
I've tried with ruby-1.9.3-p448, on a freshly provisioned box, same problem, no change.
Could you please help me?
thanks,
You haven't stated which version of the ohai and nginx cookbooks you're using.
While I can't answer your question I can provide some advice on managing your cookbooks by using a dependency manager (think bundler for cookbooks).
Install Berkshelf
gem install berkshelf
Create a Berkshelf file
$ cat Berksfile
site :opscode
cookbook "nginx"
And use this to download all the cookbooks associated with nginx:
$ berks install -p cookbooks
Using nginx (2.0.0)
Using apt (2.3.0)
Using bluepill (2.3.0)
Using rsyslog (1.9.0)
Using build-essential (1.4.2)
Using ohai (1.1.12)
Using runit (1.2.0)
Using yum (2.3.2)
The "-p" option places them in the "cookbooks" subdirectory:
$ ls -d cookbooks/*
cookbooks/apt
cookbooks/build-essential
cookbooks/ohai
cookbooks/runit
cookbooks/bluepill
cookbooks/nginx
cookbooks/rsyslog
cookbooks/yum
I have experienced the same error. You may find 3 other solutions to this problem, and an explanation why it's happening here on stackoverflow.
To mention one for those using Vagrant: Just include the recipe through Vagrantfile "chef.add_recipe()".
Using Berkshelf is obviously solving the issue, and I honestly like it. Just think that we should save the time of those who doesn't want to bother with installing new tools.
Ran into this trying to use community nexus cookbook. Solved it by specifying latest version of nginx cookbook in my metadata.rb:
depends 'nginx', '>= 2.7.6'
The nexus cookbook metadata.rb specifies:
depends "nginx", ">= 1.8.0"
So seems that chef will choose 1.8.0 when resolving deps unless you specify a newer version.
looks like ruby libraries were missing, I installed ruby by running
following command on Ubuntu and it started working for me
apt-get install ruby

Rubymine RSpec kind of error after successful test

I am a newbie just learnt how to use RSpec. My RSpec works fine in windows terminal. However, in Rubymine build-in RSpec. It errors after giving success message. Which is really annoying.
Git: https://github.com/ivawzh/sample_app
Please help.
Thanks and best regards.
RSpec works fine in native cmd
Not sure if this matters, this is the Spork drb server
Rubymine build-in RSpec, it says the tests are passed. But errors come after success message.
Error messages:
Running specs...
Command line:
["C:\\Ruby200\\bin\\ruby.exe", "-e", "$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)", "C:\\Ruby200\\bin/rspec", "--require", "teamcity/spec/runner/formatter/teamcity/formatter", "--format", "Spec::Runner::Formatter::TeamcityFormatter", "E:/RoR docs/sample_app/spec/controllers/pages_controller_spec.rb", "--drb", "--backtrace"]
2 examples, 0 failures, 2 passed
Finished in 0.17701 seconds
<-- Slave(1) run done!
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/file_utils.rb:54:in `block in create_shell_runner': Command failed with status (1): [C:\Ruby200\bin\ruby.exe -e $stdout.sync=tr...] (RuntimeError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
from C:/Program Files (x86)/JetBrains/RubyMine 5.4.2/rb/testing/runner/specs_in_folder_runner.rb:139:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
Environment:
Ruby version 2.0.0 (i386-mingw32)
RubyGems version 2.0.2
Rack version 1.5
Rails version 4.0.0
Environment development
Database adapter postgresql

Resources