In order to expand my knowledge on my own, I decided to learn the technology from open source developed by my predecessors. Therefore, it became necessary to switch the ruby environment. Since you can easily play with docker, I usually avoid switching the environment directly in the local environment.
But at this time, let's do it in the local environment! I tried to think. As a result, my understanding deepened and it was good for me.
First, from the article OSS developed with Rails, look at the OSS that looks interesting and delicious, and decide the prey.
Business System? It looks delicious
A system that issues details? Oh, it may be interesting including the management screen. https://github.com/vteams/open-source-billing/ If you just give a statement, you can look it up, but it's delicious to learn the UI
$ git clone https://github.com/vteams/open-source-billing.git
Probably a considerable amount of code. The download takes a terrible amount of time.
I can't look forward to it. I will wait while laughing.
Alright, db: create! !! !!
open-source-billing owner$ rake db:create
rake aborted!
LoadError: cannot load such file -- bundler/setup
/Users/owner/projects/oss/open-source-billing/config/boot.rb:3:in `<top (required)>'
/Users/owner/projects/oss/open-source-billing/config/application.rb:1:in `<top (required)>'
/Users/owner/projects/oss/open-source-billing/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
Wow I get an error.
LoadError: cannot load such file -- bundler/setup
As it is, the version of bundler is different. I know.
$ bundle -v
This is the version check! !!
open-source-billing owner$ bundle -v
Traceback (most recent call last):
2: from /Users/owner/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
1: from /Users/owner/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/owner/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
Hmm, can you show me the version? I see.
Let's start with Gemfile.lock
Gemfile.lock
BUNDLED WITH
2.1.4
After all, it is listed You are using 2.1.4.
Then, now my mac bundler is ...
~ owner$ bundle -v
Bundler version 2.0.2
I'm using 2.0.2, so is there an error?
that? Didn't you use 2.1.4 in the past?
$ gem list bundler
This is confirmation! !!
~ owner$ gem list bundler
*** LOCAL GEMS ***
bundler (2.0.2, 1.3.0)
capistrano-bundler (1.6.0)
I'm not using it lol Is it overlooked?
Then, let's install 2.1.4! !!
~ owner$ gem install bundler -v 2.1.4
This is the installation! !!
~ owner$ gem install bundler -v 2.1.4
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - /Users/owner/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/CHANGELOG.md
What did you say. .. .. ..
Permission denied
Because it's Permission, isn't it allowed? It seems to be related to authority
Rather than that
ERROR: While executing gem ... (Errno::EACCES)
What is this error? ?? ?? Let's google immediately.
Solution when ERROR: While executing gem ... (Errno :: EACCES) appears Thank you to our ancestors! !! !!
let's see Yeah, I don't really understand. Let's see the original article that this person referred to.
$sudo chown -R (User name):staff /Users/(User name)/.rbenv
I should do this command Because I'm using an owner account
$sudo chown -R owner:staff /Users/owner/.rbenv
I wonder, is it good It's done immediately
MacBook-Air:~ owner$ sudo chown -R owner:staff /Users/owner/.rbenv
MacBook-Air:~ owner$ gem install bundler -v 2.1.4
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Done installing documentation for bundler after 4 seconds
1 gem installed
It was a success! !! Thank you to our ancestors! !!
Let's press LGTM
Then again db: create!
$ rake db:create
Run! !!
MacBook-Air:open-source-billing owner$ rake db:create
Your Ruby version is 2.5.1, but your Gemfile specified 2.7.1
Oh, is the version of ruby different? I'm using 2.5.1, and is this OSS using 2.7.1?
For the time being, let's check which version can be installed.
$ rbenv install -l
Check it out.
OwnernoMacBook-Air:~ owner$ rbenv install -l
2.5.8
2.6.6
2.7.1
jruby-9.2.11.1
maglev-1.0.0
mruby-2.1.0
rbx-4.15
truffleruby-20.1.0
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.
Well, there is 2.7.1
Then, specify 2.7.1 and install it.
$ rbenv install 2.7.1
It's quite long. .. .. ..
OwnernoMacBook-Air:~ owner$ rbenv install 2.7.1
Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/owner/.rbenv/versions/2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/owner/.rbenv/versions/2.7.1
It's finally over! !! !!
Would you like to refresh it and reload it just in case?
Reload
$rbenv rehash
Also, since I'm using docker these days, Let's match the standard version to oss
:ruby is 2.7.Basically use 1
rbenv global 2.7.1
Then, do you want to try db: create with this?
open-source-billing owner$ rake db:create
Could not find rake-10.5.0 in any of the sources
Run `bundle install` to install missing gems.
On the other hand, it says `Run'bundle install''
``,
$ bundle install
I should do it
.
.
.
Installing libv8 3.16.14.19 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
.
.
.
An error occurred while installing libv8 (3.16.14.19), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'` succeeds before bundling.
e,,,,. Do you still get an error? ?? ??
If you look closely, it seems that there are two errors.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
Let's google from now on
[Gem::Ext::BuildError: ERROR: Failed to build gem native extension.](https://qiita.com/___xxx_/items/022595bb658f769aaa8b)
Thank you for your ancestors> <
Apparently the gem just before this error is the cause of the error
Installing libv8 3.16.14.19 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
In this case
It seems that `` libv8`` is the cause
It seems that the other error was `` libv8``
An error occurred while installing libv8 (3.16.14.19), and Bundler cannot continue.
Make sure that gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'
succeeds before bundling.
Ah, that's right.
$ gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'
Since the life is written by the above command, let's try it from here first.
$ gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'
.
.
.
An error occurred while installing libv8 (3.16.14.19), and Bundler cannot continue.
Make sure that gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'
succeeds before bundling.
Doesn't it change? T ^ T
It looks like a common error
In Gemfile: therubyracer was resolved to 0.12.3, which depends on libv8
Yeah, it seems that `` therubyracer`` is the cause
[This site](http://web-begginer-log.com/2020/01/26/rails-error-libv8/) has the same symptom, so let's try it.
### Jic incense
$ bundle config --local build.libv8 --with-system-v8 You are replacing the current $ bundle config --local build.therubyracer --with-v8-dir=$(brew --prefix v8-315)
Oh, there are no errors
Then```bundle install``Let's do it
open-source-billing owner$ bundle install
Hmm? ??
An error occurred while installing rmagick (2.15.4), and Bundler cannot continue.
Make sure that gem install rmagick -v '2.15.4' --source 'https://rubygems.org/'
succeeds before bundling.
Next time,``rmagick``Is it an error?
Perhaps ... various gems are repeated. .. .. .. ..
Let's do it anyway
$gem install rmagick -v '2.15.4' --source 'https://rubygems.org/'
open-source-billing owner$ gem install rmagick -v '2.15.4' --source 'https://rubygems.org/'
Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension.
current directory: /Users/owner/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-2.15.4/ext/RMagick
/Users/owner/.rbenv/versions/2.7.1/bin/ruby -I /Users/owner/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200730-12130-sp4zhp.rb extconf.rb checking for clang... yes checking for Magick-config... no checking for pkg-config... yes checking for outdated ImageMagick version (<= 6.4.9)... no checking for Ruby version >= 1.8.5... yes checking for stdint.h... yes checking for sys/types.h... yes checking for wand/MagickWand.h... no
Can't install RMagick 2.15.4. Can't find MagickWand.h. *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
Hmmmm ... Is it out?
Hmmmm. what
Well I do not know.
For the time being
#### **`ERROR: Error installing rmagick:`**
Let's search with.
Installation failed with gem install rmagick
Thank you for your ancestors! !! !!
let's see, Yeah, download it and put it directly on your mac...。 Alright, it's rejected. You can definitely go with a command. Because you can also download it with a command.
I wonder if there are other good articles ...
checking for Magick with gem install rmagick-config...The solution that gives no
hecking for Magick-config... no
Is suspicious?
let's see
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /Users/owner/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-2.15.4/ext/RMagick
/Users/owner/.rbenv/versions/2.7.1/bin/ruby -I /Users/owner/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200730-12130-sp4zhp.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Oh, of this erroryes
Is no problem,no
Is there a problem with? !! !!
I see! !! !!
so,Magick-config
WhenImageMagick
が怪しいWhen!!
I see, yeah! !!
Then, I will refer to the solution.
sudo: yum: command not found
Oh, can't you use it?
How to resolve command not found error I used commands casually, but I learned how there was such a difference. Besides, this person is probably the same error
$ brew install ImageMagick
Let's try this
$ brew install ImageMagick
Error: imagemagick 7.0.10-18 is already installed
To upgrade to 7.0.10-24, run `brew upgrade imagemagick`.
Yeah, it looks like it's already in. That's right, I've used it in the past.
$ brew upgrade imagemagick
I will update it for the time being
Error: Your Xcode (10.3) is too outdated.
Please update to Xcode 11.5 (or delete it).
Xcode can be updated from the App Store.
Error: Could not find an SDK that supports macOS 10.15.
You may have have an outdated or incompatible Xcode.
Homebrew found the following SDKs in the Xcode install:
10.14
Somehow, if I do more than that, I feel that the environment will be destroyed. .. .. No, it's not.
In the first place, xcode is an app that I put in for the iOS simulator.
Xcode can be updated from the App Store.
Ah, that's right.
Does that mean you should update to the latest version of Xcode? By the way, I didn't update xcode after updating mac.
So, install the latest version of Xcode from the Appp Store After that
$brew reinstall imagemagick@6
$open-source-billing owner$ gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-4.1.2
Parsing documentation for rmagick-4.1.2
Done installing documentation for rmagick after 1 seconds
1 gem installed
Oh, I succeeded! !!
Now, when I try bundle install, ...
Fetching rmagick 2.15.4
Installing rmagick 2.15.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing rmagick (2.15.4), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.15.4' --source 'https://rubygems.org/'` succeeds before bundling.
```
After all it is useless
Hmm? ?? ??
If you look closely, what is requested by the error is```rmagick (2.15.4)```So, the rmagick I put in earlier``rmagick-4.1.2``So, the error may have occurred due to the different version.
#### **`Gemfile`**
```ruby
gem 'rmagick', '4.1.2'
```
Change to.
Can I go with this? And bundle install
```
An error occurred while installing therubyracer (0.12.3), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.3' --source 'https://rubygems.org/'` succeeds before bundling.
```
``therubyracer``See you again (laughs)
I think it was solved earlier (laughs)
Is it possible to specify the version of therubyracer according to the current environment?
I think about it[article](https://note.com/konpyu/n/na213a14ad1e3)Encounter
###The era is mini_It was a racer
Haha! !!
``gem: 'therubyracer'``Is deleted! !!
#### **`Gemfile`**
```python
gem 'mini_racer'
```
instead of``mini_racer``I added
How about this! !!
```
$ bundle install
Using slim-rails 3.1.0
Using stripe 1.56.0
Fetching tinymce-rails 4.3.13
Installing tinymce-rails 4.3.13
Fetching to_words 1.1.1
Installing to_words 1.1.1
Fetching trackstamps 0.0.9
Installing trackstamps 0.0.9
Fetching twitter-bootstrap-rails 2.1.9
Installing twitter-bootstrap-rails 2.1.9
Fetching uglifier 3.0.0
Installing uglifier 3.0.0
Fetching unix_utils 0.0.15
Installing unix_utils 0.0.15
Fetching whenever 0.9.7
Installing whenever 0.9.7
Fetching wicked_pdf 2.0.2
Installing wicked_pdf 2.0.2
Fetching wkhtmltopdf-binary 0.9.9.3
Installing wkhtmltopdf-binary 0.9.9.3
Fetching xlsx_writer 0.4.4
Installing xlsx_writer 0.4.4
Fetching yajl-ruby 1.3.1
Installing yajl-ruby 1.3.1 with native extensions
Bundle complete! 104 Gemfile dependencies, 230 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from twitter-bootstrap-rails:
Important: You may need to add a javascript runtime to your Gemfile in order for bootstrap's LESS files to compile to CSS.
**********************************************
ExecJS supports these runtimes:
therubyracer - Google V8 embedded within Ruby
therubyrhino - Mozilla Rhino embedded within JRuby
Node.js
Apple JavaScriptCore - Included with Mac OS X
Microsoft Windows Script Host (JScript)
**********************************************
```
Ichiyo seems to have succeeded.
However,
```
Important: You may need to add a javascript runtime to your Gemfile in order for bootstrap's LESS files to compile to CSS.
# Important: You may need to add the javascript runtime to your Gemfile in order to compile your bootstrap LESS file into CSS.
**********************************************
ExecJS supports these runtimes:
therubyracer - Google V8 embedded within Ruby
therubyrhino - Mozilla Rhino embedded within JRuby
Node.js
Apple JavaScriptCore - Included with Mac OS X
Microsoft Windows Script Host (JScript)
**********************************************
```
It seems that you need to check if js can be used
```
ExecJS::RubyRacerRuntime is not supported. Please replace therubyracer with mini_racer in your Gemfile or use Node.js as ExecJS runtime.
# ExecJS :: RubyRacerRuntime is not supported. Replace therubyracer with mini_racer in your Gemfile or use Node.js as your ExecJS runtime.
```
Depending on the item, the above 8``mini therubyracer_Replace with racer``There is no problem as much as there are instructions.
```
$rails s
```
For the time being, let's check if the server can be started.
```
Change:
>> #<#<Class:0x00007fe292f30580>:0x00007fe29a81d588>.call(template)
To:
>> #<#<Class:0x00007fe292f30580>:0x00007fe29a81d588>.call(template, source)
(called from <top (required)> at /Users/owner/projects/oss/open-source-billing/config/application.rb:8)
[DEPRECATION] This gem has been renamed to hashie-forbidden_attributes and will no longer be supported. Please switch to hashie-forbidden_attributes as soon as possible.
```
Some gems are no longer supported``hashie-forbidden_attributes``It is said to rewrite to.
This is suspicious
```
gem 'hashie_rails', '0.0.4'
```
gem 'hashie_rails'Let's take a look at github.
```
HashieRails
Moved to HashieForbiddenAttributes.
```
Oh! After all,``hashie-forbidden_attributes``It has changed to! !!
```
gem 'hashie-forbidden_attributes'
```
Rewrite to this,``bundle install``To do.
```
$ rails s
```
Can it be started with this? ?? ?? ??
```
$ rails s
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
>> #<#<Class:0x00007f9aa1b5e5f8>:0x00007f9aa1b574b0>.call(template)
To:
>> #<#<Class:0x00007f9aa1b5e5f8>:0x00007f9aa1b574b0>.call(template, source)
(called from <top (required)> at /Users/owner/projects/oss/open-source-billing/config/application.rb:8)
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
```
It's no good
```
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
```
warning:Single-arity template handlers are deprecated. Template handler
It now accepts two parameters, the view object and the source of the view object.
It seems to mean that.
I will search for it for the time being.
[【Rails6】DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must now accept two parameters, the view object and the source for the view object.](https://qiita.com/mishiwata1015/items/7bd39f0400421b9264f7)
It came out
I really appreciate it.
I will try it once
```
$ bundle update slim
```
If this doesn't work,
https://github.com/rails/rails/issues/35505
I would like to try the method of.
```
$ rails s
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
>> #<#<Class:0x00007f8216263780>:0x00007f8211d3abe0>.call(template)
To:
>> #<#<Class:0x00007f8216263780>:0x00007f8211d3abe0>.call(template, source)
(called from <top (required)> at /Users/owner/projects/oss/open-source-billing/config/application.rb:8)
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
Exiting
```
It is useless
#### **`Gemfile`**
```python
gem 'slim', '3.0.7'
```
Let's delete this.
```
$ rails s
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
>> #<#<Class:0x00007fe53a1117b0>:0x00007fe53a132ff0>.call(template)
To:
>> #<#<Class:0x00007fe53a1117b0>:0x00007fe53a132ff0>.call(template, source)
(called from <top (required)> at /Users/owner/projects/oss/open-source-billing/config/application.rb:8)
```
It is useless
Then this[article](https://github.com/rails/rails/issues/35505)I will refer to.
#### **`Gemfile`**
```ruby
gem 'jbuilder', '~> 2.0'
gem 'jbuilder', github: 'rails/jbuilder', branch: 'master'
```
Let's do it with this
``bundle update``I'm instructed to do it, so I'll leave it first.
```
$ rails s
```
```
$ rails s
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
Exiting
Traceback (most recent call last):
50: from bin/rails:4:in `<main>'
49: from bin/rails:4:in `require'
```
The previous error is gone, but it still doesn't seem to load.
#### **`error`**
```python
`database_configuration': Cannot load database configuration: (RuntimeError)
Could not load database configuration. No such file - ["config/database.yml"]
```
Apparently database in config folder.It doesn't seem to contain yml.
database.Adding yml will improve it.
before that
I erased it earlier``slim``Let's go back and verify
#### **`Gemfile`**
```ruby
gem: 'slim'
```
Start with this
```
$ rails s
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
Exiting
Traceback (most recent call last):
```
Yeah yeah
```
Change:
>> #<#<Class:0x00007fe53a1117b0>:0x00007fe53a132ff0>.call(template)
```
Slim doesn't seem to be relevant because there is no.
Thanks,Looks like a bug in rails 6 jbuilder
Then continue to database.I will create yml.
#### **`config/database.yml`**
```yml
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
host: localhost
development:
<<: *default
database: open-source-billing_development
test:
<<: *default
database: open-source-billing_test
```
With this, for the time being``rails s``I will try.
```
/Users/owner/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych.rb:577:in `initialize': No such file or directory @ rb_sysopen - /Users/owner/projects/oss/open-source-billing/config/config.yml (Errno::ENOENT)
```
Hmm
For the time being``No such file or directory @ rb_sysopen``When you google[article](https://qiita.com/minoriinoue/items/7e538c650c1037d962b0)Came out
It seems that something is missing
In this case``config/config.yml``It seems that it is occurring because there is no.
However,``config/config.copy.yml``Because the file called was prepared,``copy``Erase the description of``cofig.yml``It was made.
```
$ rails db:create
Created database 'open-source-billing_development'
Created database 'open-source-billing_test'
$rails db:migrate
Zugagagagagaga .....
$rails s
Ah ah ah ah ah ah ah ah ah ah ah It's finally oh
Recommended Posts