2016年1月27日水曜日

Vagrant で shell-provisioning する時に.bashrc が読み込まれない

shell provisionした際に、以下のエラーが出てrbenvやnvmやnpmが実行できなかった。

==> default: /tmp/vagrant-shell: line 21: rbenv: command not found

==> default: /tmp/vagrant-shell: line 62: nvm: command not found

==> default: /tmp/vagrant-shell: line 63: npm: command not found


原因は以下の記事で判明。

Vagrantでshell-provisioningする時のshell環境に関するメモ - Qiita


.bashrc の先頭に、コマンドライン(非interactive)の時に、読込を終了する様な記述があったため。

但し、上記の記事とは違い、.bashrcの先頭の記載は下記であった。

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

そのため元記事にあるような

こうしたら動いた。

# set interactive environmental-valiables

PS1='$ '

source ~/.bashrc

# Install ruby

rbenv install 2.1.1

rbenv global 2.1.1

ではうまく行かず。。


echo $-

を確認した結果ところ

hB

となっていたので、 shel provision の冒頭で

set -i

することで.bashrcが無事読み込まれるようになりました。

  config.vm.provision "shell", privileged: false, inline: <<-SHELL
    set -i
    source ~/.bashrc

2015年10月14日水曜日

bloggerへのはてなブックマークボタンの設置

こちらの記事を参考に、
Blogger記事に「はてなブックマーク」ボタンを設置する方法 | Asterlist
http://blog.asterlist.com/2012/11/1001.html
公式ページで発行した最新の埋め込みタグ(https対応版)とマージして微調整した、以下のタグを埋め込むことにしました。

<div class='goog-inline-block'>
  <a expr:href='"http://b.hatena.ne.jp/entry/" + data:post.canonicalUrl' class="hatena-bookmark-button" expr:data-hatena-bookmark-title='data:post.title' data-hatena-bookmark-layout="simple-balloon" title="このエントリーをはてなブックマークに追加">
    <img src="https://b.st-hatena.com/images/entry-button/button-only@2x.png" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" />
  </a>
  <script type="text/javascript" src="https://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async">
  </script>
</div>

ただ、参考記事のように `「data:post.body」の直下に記述` だとうまく表示されませんでした。
テンプレートは「シンプル」を使っています。
そこで、Googleが元々提供しているSNSボタンがあるので、並べるような形で以下の位置に埋め込んでみたら、いい感じに馴染んでくれました!
1466行目~
  • 変更前
                              <b:includable id='shareButtons' var='post'>
                                <b:if cond='data:top.showEmailButton'>
                                  <a class='goog-inline-block share-button sb-email' expr:href='data:post.sharePostUrl + &quot;&amp;target=email&quot;' expr:title='data:top.emailThisMsg' target='_blank'>
                                    <span class='share-button-link-text'>
                                      <data:top.emailThisMsg/>
                                    </span>
                                  </a>
                                </b:if>
  • 変更後
                              <b:includable id='shareButtons' var='post'>
                                <div class='goog-inline-block'>
                                  <a class='hatena-bookmark-button' data-hatena-bookmark-layout='simple-balloon' expr:data-hatena-bookmark-title='data:post.title' expr:href='&quot;http://b.hatena.ne.jp/entry/&quot; + data:post.canonicalUrl' title='このエントリーをはてなブックマークに追加'>
                                    <img alt='このエントリーをはてなブックマークに追加' height='20' src='https://b.st-hatena.com/images/entry-button/button-only@2x.png' style='border: none;' width='20'/>
                                  </a>
                                  <script async='async' charset='utf-8' src='https://b.st-hatena.com/js/bookmark_button.js' type='text/javascript'>
                                  </script>
                                </div>
                                <b:if cond='data:top.showEmailButton'>
                                  <a class='goog-inline-block share-button sb-email' expr:href='data:post.sharePostUrl + &quot;&amp;target=email&quot;' expr:title='data:top.emailThisMsg' target='_blank'>
                                    <span class='share-button-link-text'>
                                      <data:top.emailThisMsg/>
                                    </span>
                                  </a>
                                </b:if>

2015年10月5日月曜日

OSX 10.11 (El Capitan) でUSB <=> RJ45 変換アダプタ (USB 10/100 LAN) が動作しない

OSX を El CapitanにアップデートしたらUSB(2.0)接続のLANケーブル変換アダプタ(Cable Matters社製)が認識されなくなった。

いろいろ調べたところ以下の投稿を発見。

USB 2.0 to Ethernet Adapter not detected as net... | Apple Support Communities https://discussions.apple.com/message/28327141#28327141

上記の以下のコメント、

After downloading and installing these:

http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=14&PFid=55&Level=5&Conn=4&DownTypeID=3&GetDown=false\

It does finally show up as a USB Ethernet Device...

と記載されていたので、信じて realtek のサイトからOSX (10.10マデ用になっていましたが)をダウンロードしてインストールしたところ無事認識されるように!

よかった!

2015年1月29日木曜日

/etc が謎の肥大化。原因はetckeeper (.git/)。


# du -hsc /etc*
15G total
# du -hs /etc/*
(略)
81M total

なぜだ・・・
と思ったら隠しディレクトリに原因が。


# du  -hsc /etc/.*
15G     /etc/.
du: cannot access `/etc/../proc/14172/task/14172/fd/4': No such file or directory
du: cannot access `/etc/../proc/14172/task/14172/fdinfo/4': No such file or directory
du: cannot access `/etc/../proc/14172/fd/4': No such file or directory
du: cannot access `/etc/../proc/14172/fdinfo/4': No such file or directory
16G     /etc/..
8.0K    /etc/.etckeeper
15G     /etc/.git
4.0K    /etc/.gitignore
0       /etc/.pwd.lock
45G     total

なんで/etcに.gitがあんねん!ひょっとして間違ってうっかり git init でもやっちゃったのかなぁ心当たりないなぁ。
と思って軽く調べてみたらetcのバージョン管理を自動でやってくれるetckeeperという仕組みが勝手にデイリーでコミットし続けてくれている事が発覚。

etckeeper 肥大化 とか etc 肥大化 とかで検索しても大した情報は見つからなかったのですが、
とりあえず


# cd /etc
# git gc
Counting objects: 28413, done.
Compressing objects: 100% (26954/26954), done.
Writing objects: 100% (28413/28413), done.
Total 28413 (delta 21602), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.
# du -hsc /etc/.git
45M /etc/.git
45M total

スッキリしたみたいです。


2015年1月23日金曜日

Jenkinsで bundle install --path=vender/bundler が失敗する場合の対処法

以下のようなエラーが出ていろいろ試行錯誤した結果、nokogiriをビルドするためには、パスに空白があるといけないということが判明。。
Jenkinsのジョブ名を空白なしに修正unit testunit_testしたら先に進めた。。。
(ジョブ名を変えればディレクトリ名も自動的に変わる模様)

~~~
Building in workspace /var/lib/jenkins/jobs/unit test/workspace


git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url /var/opt/alminium/git/* # timeout=10
Fetching upstream changes from /var/opt/alminium/git/

git --version # timeout=10
git fetch --tags --progress /var/opt/alminium/git/
* +refs/heads/:refs/remotes/origin/
git rev-parse refs/remotes/origin/proto^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/proto^{commit} # timeout=10
Checking out Revision 7145731f308fec32fe9c84f32733fc4cfa0b91a9 (refs/remotes/origin/proto)
git config core.sparsecheckout # timeout=10
git checkout -f 7145731f308fec32fe9c84f32733fc4cfa0b91a9
git rev-list 7145731f308fec32fe9c84f32733fc4cfa0b91a9 # timeout=10
[workspace] $ /bin/sh -xe /tmp/hudson8128990982305471465.sh
+ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies......
Using rake 10.4.2
Using i18n 0.7.0.beta1
Using json 1.8.1
Using minitest 5.5.0
Using threadsafe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.2.0.rc1
Using builder 3.2.2
Using erubis 2.7.0
Using mini
portile 0.6.1


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb 

/usr/bin/ruby: invalid option -u (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /var/lib/jenkins/jobs/* unit test/workspace/vendor/bundler/ruby/2.1.0/gems/nokogiri-1.6.5 for inspection.
Results logged to /var/lib/jenkins/jobs/
*
unit test/workspace/vendor/bundler/ruby/2.1.0/extensions/x8664-linux/2.1.0/nokogiri-1.6.5/gemmake.out
An error occurred while installing nokogiri (1.6.5), and Bundler cannot
continue.
Make sure that gem install nokogiri -v '1.6.5' succeeds before bundling.
Build step 'Execute shell' marked build as failure
Build step 'Aggregate Redmine ticket metrics' marked build as failure
Finished: FAILURE
~~~


2014年12月7日日曜日

google authenticatorは機種変更時に情報が引き継がれないので要注意

AWSのmfaを解除するにはサポートに問い合わせて電話で確認コードを読み上げる(英語)必要があるらしい。

めんどいな。。
個人アカウントは情報控えてなかっただろうなぁ。

2014年11月28日金曜日

WindowsのSourceTreeでGit Pull/Pushが異様に遅い

内蔵GitにしてもシステムGitにしてもダメ。
なお、システムGit(git 2.1.1)は、コマンドラインから実行すると早い。

.git/config
を開いて

[remote "origin"]
url = https://hogehoge.hogehoge

のところを

[remote "origin"]
url = https://user@password:hogehoge.hogehoge

のように、IDとパスワードを入れたら復活した。
が、あんまり気分の良い解決策じゃないなぁ。
その後色々いじってみたが根本解決策は不明。

ちなみに、msysGit(git version 1.9.4.msysgit.2)のGit Bashは、上記対応を実施しても未だに遅い。

謎だ。。