2017 06,15 03:02 |
|
ruby on rails を勉強中です。
前に、作ったrubyのプロジェクトと同じ階層に新たなプロジェクトを生成 # rails new プロジェクト名 create
create README.md
create Rakefile ~ 略 ~ Bundle complete! 16 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
The latest bundler is 1.15.1, but you are currently running 1.15.0.
To update, run `gem install bundler`
run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
# rails s と入力すると /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.3.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/lib/ruby/gems/2.3.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/2.3.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler.rb:108:in `require'
/var/www/ruby_test/railbook/config/application.rb:7:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:129:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:129:in `block in perform'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:126:in `tap'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:126:in `perform'
/usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/command/base.rb:63:in `perform'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/command.rb:44:in `invoke'
/usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands.rb:16:in `<top (required)>'
/var/www/ruby_test/railbook/bin/rails:9:in `require'
/var/www/ruby_test/railbook/bin/rails:9:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/var/www/ruby_test/railbook/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `each'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `block in require'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler.rb:108:in `require'
from /var/www/ruby_test/railbook/config/application.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:129:in `require'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:129:in `block in perform'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:126:in `tap'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands/server/server_command.rb:126:in `perform'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/command/base.rb:63:in `perform'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/command.rb:44:in `invoke'
from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.1.1/lib/rails/commands.rb:16:in `<top (required)>'
from /var/www/ruby_test/railbook/bin/rails:9:in `require'
from /var/www/ruby_test/railbook/bin/rails:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /usr/local/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /var/www/ruby_test/railbook/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
勘弁してくれ・・・ 仕方ないので、色々調べてみると もう作ってあるなら、そのプロジェクトフォルダに移動しないとだよ ということか? と思い、 # cd プロジェクト # rails s ~ 同じ ~ さらに調べて Gemfile を修正してみて成功したという例を発見 # vi Gemfile # gem 'therubyracer', platforms: :ruby となっている部分のコメントを外す gem 'therubyracer', platforms: :ruby # rails s => Booting Puma
=> Rails 5.1.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.3-p222), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
起動!!! それなら最初から外しておいてくださいよ。。。 確実に、同じことにはまりそうなので、ここに記載 PR |
|
2017 06,12 19:48 |
|
久しぶりにJAVAをやったら、スレッドセーフの問題に嵌りました
詳しくは、こちらに書いてあります。
http://www.symmetric.co.jp/blog/archives/20
http://se35over.seesaa.net/article/286645037.html 僕も、DateFormatのスレッドセーフ問題で
部分的に、synchronized をしても、ダメでしたので、
僕の場合は、メソッド自体をsynchronized することに。
まぁログを書く処理だから、メソッドをsynchronizedしても問題ないでしょう。
これが、くっそ重い処理だったら、メソッドにsynchronized をするのは
かなり問題が出てくると思いますが。
やっぱり、PHPばっか(特にバージョンが古いPHP)をやってると
頭が悪くなるなって痛感した日でした。
|
|
2017 06,12 13:30 |
|
Tomcatのcatalina.outが肥大化していたのでローテーションを行う設定に
しかし、方法がいくつかあるみたい しかも、tomcatのログのパスが異なるので、 自分の環境に合うパスの設定を行ってみました。 /usr/local/tomcat/logs/catalina.out {
missingok
copytruncate
daily
sharedscripts
postrotate
EXT=`date +%Y%m%d`
for f in $1;
do mv $f.1 $f.$EXT;
done
endscript
} ポイントは、copytruncate のようです。 tomcatは、logrotateのsyslogなどのデフォルトの設定をコピーして使用すると、 tomcatがログ・ファイルを掴んだ状態になってしまう とのこと /usr/sbin/logrotate -d /etc/logrotate.d/tomcat で確認 大丈夫そうなので、1度だけど強制に実行をしました。 /usr/sbin/logrotate -f /etc/logrotate.d/tomcat 強制的に実行した際は、問題なし。ちゃんと明日は、ローテーションされているかな? |
|
2017 06,07 17:12 |
|
2017 05,22 17:39 |
|
こいつも嵌りました。。。。
1日で2つの異なる環境をつくるもんじゃないね。。。
まず、gitインストール
$ yum install git
パッケージインストール
$ yum install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel
rubyインストール
$ git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
$ echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile
$ echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
$ echo 'eval "$(rbenv init -)"' >> /etc/profile
$ source /etc/profile
バージョンの確認
$ rbenv --version
ruby-buildインストール
$ git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
$ rbenv install -l
$ rbenv install -v ヴァージョン
$ rbenv rehash
これで、インストールできず。。。
仕方ないので、
$ wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz
$ tar zxvf ruby-2.3.3.tar.gz
$ cd ruby-2.3.3
$ ./configure
$ make
$ make install
$ gem update --system
で、アップデートをさせました
試しに、プロジェクトを作ってみることに
$ rails new test_ruby
$ rails g controller users index show
これでエラーになったので。。。
$ gem install --no-ri --no-rdoc rails
$ gem install bundler
とやってもダメ
アプリケーション内のGemfileファイルを編集
#gem 'therubyracer', platforms: :ruby となっている部分の下に
gem 'therubyracer' と記述
$ bundle install
$ bundle update
インストールして、アップデートもしてみた
そして、再度実行
$ rails g controller users index show
おぉ~、エラーが消えた!!!
Ruby on Railsの環境作りも面倒。。。
Ruby on Railsは、絶対にすんなり環境構築は出来ないものだと確信をしました。
参考
https://readouble.com/laravel/4.2/ja/quick.html
http://qiita.com/shinyashikis@github/items/3501c5f7f71a8e345c3d
http://qiita.com/kshimadutsu/items/26aff85950fa28fffc09
http://qiita.com/cosuprog/items/2f6bdf6e4119cb20058b
http://krs1.hatenablog.com/entry/2016/05/30/120000 |
|
忍者ブログ [PR] |