Arduino IDE使うのやめて、Sublime Text + Deviotを使う

概要

言いたいことは1つ

Arduino IDEのエディタ機能でプログラミングすることに耐えられない

違う環境を探すことにした

候補

  • Vim
    • 一応できる
      • 環境構築に時間がかかりそう
      • シリアルポートの切り替えでどっちにしてもArduino IDE使うことになりそう
  • Sublime Text
    • パッケージ1つ入れるだけでほぼすべてのことができる
      • シリアルモニタもSublime Textで表示できる
    • 完璧じゃないけど、補完機能が使える

Sublime Text + を使って環境を整えることにした f:id:siragumohuin:20161015224751p:plain

環境構築方法

前提条件

  • Sublime TextでPackageのインストールができる状態になっている
    • わからなかったら、ここまではググれば余裕でできるはず
  • Arduino IDE自体はインストール済み
  • Macでしか確認してないです

Deviotのインストール

  1. コマンドパレットを開く
    • shift + command + P
    • 僕はVimっぽくescして、COMMAND MODEにしてから:でパレットを開いてます
  2. install Packageと入力して選択(推測されるので途中まで入力すればいいと思う)
  3. Deviotで入力して選択(これも推測されるので途中まで入力すればいいと思う)
  4. ちょっと待てばインストールが終わります
  5. 上のヘルプの右にDeviotが表示されていれば成功

使い方

読めばわかる(素晴らしい)
使いそうなものだけ

  • Select boart
    • Arduinoの種類を選べる。自分の使ってるやつを選ぼう
  • Build
    • IDEでいう検証
  • Upload
  • Monitor Serial
    • シリアルモニタをSublime Textで表示できる

補足

  • Pythonへの使用許可を求められる
    • 2台使ってi2c通信するとき、シリアルポートを切り替える毎に出るのがツライ
    • 対策方法は現状調べてない f:id:siragumohuin:20161015224755p:plain
  • 僕の場合、Arduino IDEへのパスの設定を特別しなくてもよかった
    • デフォルトの位置にインストールしてないときは変更する必要がありそう
  • DeviotはArduino-like IDEの後継(?)
    • 最初、Arduino-like IDEをインストールして残念な気持ちになった

おわりに

少しはArduinoのプログラミングをする気になりました

Sorry, this command is disabled, the Python's site module could not be loaded

brew upgradeしたら、vimにこんなエラーが出るようになった
(brew cleanupもした)

Error detected while processing function <SNR>23_InitializePythonBuiltin:
line   23:
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
Press ENTER or type command to continue

まぁ、読んだ通りのエラー
python関係が弄られちゃったかな
brew upgradeの内容は以下

$ brew upgrade
==> Upgrading 11 outdated packages, with result:
harfbuzz 1.3.2, mpfr 3.1.5, node 6.7.0, postgresql 9.5.4_1, pyenv 1.0.2_1, python 2.7.12_1, python3 3.5.2_2, readline 7.0, redis 3.2.4, ruby 2.3.1_1, sqlite 3.14.2_1

ありがたいことに、直し方をまとめてくれている人がいた

Vimで'E887: Sorry, this command is disabled, the Python's site module could not be loaded.'なエラー

私の場合も

brew reinstall vim --HEAD

これで直りました

GitLabの更新 その3

使えるようになった機能

修正に苦しんだこと

  • Raw表示

なんでRaw表示できないのか?

“raw” display for files does not work

他にもRaw表示できないという報告はちらほらされている様子
だが、再現性のない不具合のようで、抜本的な解決がされてないようだ
この不具合はGitLabに内蔵されているnginxではなく、
aptとかで普通にインストールされたnginxを使った場合に起こる
リバースプロキシを使うことになるのだが、GitLabが上手く動作しなくなることがある様子

GitLab構成

Workhorseが悪いのか、Unicornが悪いのかわからん…
再インストールもしてみたが、sshとかの設定を壊さない程度にやったので完璧じゃない
更新頻度も高いし、Updateも簡単なので、とりあえず様子見しようと思う

実は直ってたやつ

なぜか表示できるようになってた
自分でテスト用に作ったレポジトリのRaw表示ができなかったのだが、
先生のレポジトリでtexをRaw表示したら見れた
コミットし直したら自分のレポジトリのRaw表示もできるようになった

コミットし直さないとRaw表示してくれないという罠

この更新作業でLinuxコマンドをいろいろ調べて、実際に使ってみれたので勉強になった

GitLabの更新 その2

エラーチェック

エラーチェックコマンドがわかったので、やってみた

sudo gitlab-rake gitlab:check SANITIZE=true

結果

-> % sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab Shell ...

GitLab Shell version >= 3.4.0 ? ... OK (3.4.0)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ...
2/2 ... ok
~~~~~~~~~~~~~~
略
~~~~~~~~~~~~~~
19/198 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: FAILED: Failed to connect to internal API
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Reply by email ...

Reply by email is disabled in config/gitlab.yml

Checking Reply by email ... Finished

Checking LDAP ...

LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab ...

Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... no
  Try fixing it:
  sudo chown -R git /var/opt/gitlab/gitlab-rails/uploads
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} \;
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} \;
  For more information see:
  doc/install/installation.md in section "GitLab"
  Please fix the error above and rerun the checks.
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ...
2/2 ... yes
~~~~~~~~~~~~~~
略
~~~~~~~~~~~~~~
19/198 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.1)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.7.4)
Active users: 52

Checking GitLab ... Finished

2箇所エラーが出た。

エラー1

Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: FAILED: Failed to connect to internal API
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.

Checking GitLab Shell ... Finished

/etc/gitlab/gitlab.rb

# Set the internal API URL
gitlab_rails['internal_api_url'] = 'https://gitlab.moongdal.net'

設定しない方がよかった様子
コメントアウトした

エラー2

Uploads directory setup correctly? ... no
  Try fixing it:
  sudo chown -R git /var/opt/gitlab/gitlab-rails/uploads
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} \;
  sudo find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} \;
  For more information see:
  doc/install/installation.md in section "GitLab"
  Please fix the error above and rerun the checks.

こいつは指示通りやればエラーが消えた

最終的に

ダウンロードできない不具合は直らなかった

GitLabの更新 その1

事の始まり

研究室のGitLabがかなり古かった
その時にまとめたブログ

2016/09/10での最新版:8.11.5
研究室のGitlab:8.1.3

Webから、アーカイブ(zipでまとめてくれる)がダウンロードできないバグがあったので、夏休み中にUpdateしたいと思った

状況確認

研究室のGitlabはVPSで動いている

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"

研究室にGitlabを導入したのは先輩で多少アプデしてそのままのようだ

拾えた情報

  • omnibusのGitLabを導入
  • nginxはaptで入れたものを使用
  • https(port番号443)のみで動かしてる

GitLabの構成

ディレクトリ構成

  • /opt/gitlab
  • /var/opt/gitlab
  • /var/log/gitlab
  • /etc/gitlab

ソフトウェア構成

  • git
  • Ruby
  • Ruby on Rails
  • runit
    • スーパーデーモン
  • nginx
    • フロントエンド Web サーバー (無効化可能)
    • デフォルト TCP ポート: *:80
  • Unicorn
    • バックエンド Web サーバー (Rails 実行環境)
    • デフォルト TCP ポート: 127.0.0.1:8080
    • デフォルト UNIX ドメインポート: /var/opt/gitlab/gitlab-workhorse/socket
  • PostgreSQL
    • デフォルトポート: /tmp/.s.PGSQL.5432
  • Redis
  • Chef
  • そのほか

詳細は以下のページ

https://docs.gitlab.com/ce/development/architecture.html

設定ファイルの場所

  • /etc/gitlab/gitlab.rb
    • GitLabの各種設定を行う
  • /etc/nginx/conf.d/gitlab.conf
    • このGitlabはGitlab内蔵のnginxを使っていないのでここで設定

UpdateするまえにBackup

sudo gitlab-rake gitlab:backup:create

/var/opt/gitlab/backups/以下にtar形式でBackupされる

Update

バージョンによって多少手順が違うらしい

Updating GitLab via omnibus-gitlab

とりあえず、Updating from GitLab 6.6 and higher to 7.10 or newerを見ながらやった

apt-getすればいいだけだった
アクセスしたら500エラーになって焦ったけど、Ubuntuを再起動したら直った

不具合

不具合を列挙する(修正済みを含む)

ログアウトするとGitLabに入れなくなる

[修正済み]
他の不具合を修正するためにいろいろ設定をいじったらなった
たぶん、port周りの設定をミスってた

Gravatar表示ができない

先生はGravatarでアイコンを表示していたのだが、表示されなくなる不具合
原因は、フロントエンド Web サーバー(nginx)の実行ユーザーが指定されてなかったせい
/etc/gitlab/gitlab.rb

web_server['external_users'] = ['www-data']

と追記

アーカイブがダウンロードできない

[修正済み]
一番の問題だった
ググっても同じ不具合が起こっている人がいない(英語圏も含め)

後述するRAW表示や個別のファイルダウンロードができないというlssuesがあった

Getting raw files over http/https not working in 8.5.x

Vhost (server block)

こいつのVhost (server block)をnginxの設定(/etc/nginx/conf.d/gitlab.conf)に加えたらアーカイブのダウンロードが可能になった

RAW表示や個別のファイルダウンロードができない

[未解決]
原因不明。上記のissuesを修正すればいいと思ったのだが、直らず
-> 直ってた。詳しくは siragumohuin.hatenablog.com

怪しい部分「gitlab-workhorse」

workhorseって何?

gitlab-workhorse

gitlab-workhorseはファイルのダウンロード、ファイルのアップロード、Gitのpush/pullとかGitのアーカイブダウンロードなどのデカイHTTP要求を処理するらしい

高負荷に耐えられるように設置されたという歴史があるっぽい

A Brief History of GitLab Workhorse