note: module requires Go 1.13がHerokuで出る

go.modにversionを指定しているのですが、なぜかタイトルのエラーが発生しました

 !!    The go.mod file for this project does not specify a Go version
 !!    
 !!    Defaulting to go1.12.17
 !!    
 !!    For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration

golang.org/x/text/secure/precis
# github.com/jackc/pgtype
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/aclitem_array.go:89:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/bool_array.go:92:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/bpchar_array.go:92:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/bytea_array.go:73:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/cidr_array.go:112:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/date_array.go:93:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/enum_array.go:89:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/float4_array.go:92:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/float8_array.go:92:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/hstore_array.go:73:49: reflectedValue.IsZero undefined (type reflect.Value has no field or method IsZero)
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgtype@v1.10.0/hstore_array.go:73:49: too many errors
note: module requires Go 1.13
github.com/jackc/pgx/v4/internal/sanitize
github.com/jackc/pgconn
# github.com/jackc/pgconn
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgconn@v1.11.0/errors.go:25:9: undefined: errors.As
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgconn@v1.11.0/pgconn.go:236:6: undefined: errors.As
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgconn@v1.11.0/pgconn.go:485:6: undefined: errors.As
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgconn@v1.11.0/pgconn.go:495:15: undefined: errors.As
../codon/tmp/cache/go-path/pkg/mod/github.com/jackc/pgconn@v1.11.0/pgconn.go:513:15: undefined: errors.As
 !     Push rejected, failed to compile Go app.
 !     Push failed

Goのバージョンは下記のように固定しているのですが、なぜかHerokuではタイトルのように、1.12.17が適用されてしまいます

module go-api

go 1.18

HerokuでGoのバージョンを指定するためには、コメントで下記のように追加する、もしくはHerokuのdashboardの変数管理の場所で、追加しても動くそうです(私は未確認)

// +heroku goVersion go1.18
go 1.18
Go + Herokuの設定方法

参考記事

go.mod に書かれた Go のバージョンが Heroku に認識されない

Defaults to v1.11.x version, despite “go 1.12” in go.mod file #301

call dein#recache_runtimepath()でUndefined variable: v:luaエラー

deinのcacheを削除してもう一度再生成を試みていたところタイトルのエラーが発生しました

cacheを再生成したにも関わらず更新されない場合は、こちらのコマンドを実行することでマニュアル削除できる、とのことでしたが、そもそもそれが実行できなく、どうしようもない状態でした。

※こちらがキャッシュ強制削除コマンド

:call dein#recache_runtimepath()

結論

nvimをupdateしたら直りました

update前は0.4.4?あたりのversionで、最新版は0.7.0ということで、もしかしたら?と思って

まずはupdateして

こちらを実行してみたら

:call dein#recache_runtimepath()

エラーが出ずに、キャッシュクリアして元通りとなりました!!!

nvimの再インストール手順

# 既存のnvimをuninstall
sudo rm /usr/local/bin/nvim
sudo rm -r /usr/local/share/nvim/

# nvimをclone
git clone https://github.com/neovim/neovim.git

# install. sudo make installでエラーが出る場合は下記を参考に¥
cd neovim
make CMAKE_BUILD_TYPE=Release
sudo make install

こんな感じのエラー出る場合は

CMake Error at runtime/cmake_install.cmake:77 (file):
  file cannot create directory:
  /usr/local/share/nvim/runtime/pack/dist/opt/matchit/doc.  Maybe need
  administrative privileges.
Call Stack (most recent call first):
  cmake_install.cmake:86 (include)

こちらを実行して、ディレクトリを作成、そして実行

mkdir /usr/local/bin/nvim
mkdir /usr/local/share/nvim/

# 作成したら再度実行
sudo make install

完了したら、vimを一旦落としてまた立ち上げると動いています!!!!

動いていることと、便利な機能を提供してくれている作者さん等々に感謝です!!!!!

参考記事

neovimのアップデート

vimのnextが遅い場合の対処法

vimでnextが非常に遅く(nをクリックしてから1秒ぐらい経過)とてもじゃないけど、作業できない状態で作業してました

そんな時にvim仲間の作業を見ていたところ、非常に早い動作をしていたのでgoogleで検索してみたところ、timeを設定できるらしく、こちらを入力したところ問題を解消することができました

:set timeoutlen=100 ttimeoutlen=100

注意点

timeoutを設定すると

  • fzf
  • tree

等のコマンド入力に対する時間(コマンドを打つ間隔)も短くなるので、素早く打つ必要が出てしまいます

また上記コマンドだと毎回入力する必要があるので、下記の設定を.vimrcに追加して、入力間隔を200に設定することでいい感じにしました🙌

set timeoutlen=200 ttimeoutlen=0

参考記事

my vim jump to next word is quite slow, what am I doing wrong?

coc + neovimでkotlinを使う方法

Android開発をAndroid studioではなくvimで行いたくて、色々と詰まった箇所あるので記事にしてみました

手順

Kotlinのinstall

まずはbrew経由でinstall

brew install kotlin

kotlin --version
Kotlin version 1.6.10-release-923 (JRE 17.0.2+0)

Syntax系

[[plugins]]
repo = 'udalov/kotlin-vim'
on_ft = ['kotlin']

# .vimrcにはこちらも追加。kotlinファイルをうまく認識してくれなかったので入れました
autocmd BufReadPost *.kt setlocal filetype=kotlin

lspの設定

まずはkotlin lspをclone

fwcd/kotlin-language-server

https://github.com/fwcd/kotlin-language-server.git

cd ../kotlin-language-server
./gradlew build

cloneが完了したら、coc-settingにこちらを追加

"kotlin": {
    // LSPをdownloadしたpathを入れる
    "command": "/Users/masahirookubo/development/kotlin-language-server/server/build/install/server/bin/kotlin-language-server",
    "filetypes": ["kotlin"]
}

若干動作が遅い気もしますが、上記の対応でneovimでAndroid開発をサクサク(一応)行えるようになりました!

参考記事

Building

Editor Integration

Rails + ransackで正しいはずなのになぜか検索が思っていた通りに動かない時の参考点

結論、enumでintではなくstringで検索していたから、です

通常のstringなら動いているのですが、enurmrizeを使ったenumのカラムのみなぜか検索が効かずに、どんな手法を通じませんでした。。。

色々と検索している際に、active adminの検索もintじゃないと動かないことを思い出し、実装してみたところ動きました🙌

こちらコード

# 動かないコード
= link_to jobs_path(q: { kind_eq: 'hogehoge' })

# 動くコード
= link_to jobs_path(q: { kind_eq: 1 })

参考記事

なし、思いつきました

Next.jsのrouterでundefinedが出る問題

Next.jsでrouter経由でparamsを取得しようとした際に、undefinedが出る問題が発生しましたが、下記のようにreadyしたタイミングに変更したところ、問題なく動きました

const router = useRouter();
useEffect(()=>{
    if(!router.isReady) return;
}, [router.isReady]);

参考記事

useRouter/withRouter receive undefined on query in first render

graphql-clientでKeyError: key not found: “data”が出る

Railsでwordpressからgraphql経由で記事取得しようとしたら、タイトルのエラーが発生しました

該当箇所は以下の部分で、おそらくschemaを読み込んでいると思うのですが、

Schema = GraphQL::Client.load_schema(HTTP)

なぜかdataがないです、というエラーが発生してます

queryを投げてdataがない、というのであれば理解できるのですが、query以前の問題だったので、
途中で解決は諦めて下記のようにhttpで対応する方針にした結果、すぐ解決できました🙌

query = <<-'GRAPHQL'
      query Posts {
        posts(first: 5) {
          edges {
            node {
              title
              excerpt
              slug
              date
              featuredImage {
                node {
                  sourceUrl
                }
              }
              categories {
                edges {
                  node {
                    name
                  }
                }
              }
            }
          }
        }
      }
    GRAPHQL
    uri = URI('https://hoge/graphql')
    res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
      req = Net::HTTP::Post.new(uri)
      req['Content-Type'] = 'application/json'
      # req['Authorization'] = "Bearer #{accessToken}"
      # The body needs to be a JSON string.
      req.body = JSON[{'query' => query}]
      puts(req.body)
      http.request(req)
    end
    puts(res.body)

参考記事

`fetch’: key not found: “data” (KeyError) : graphql-client error

KeyError: key not found: “data” #1956

GraphQL via HTTP in five ways: cURL, Python, JavaScript, Ruby and PHP

EC2 + wordpressで画像更新できない、plugin追加できない解消法

EC2にwordpressを設定して、色々修正を加えているうちになぜか

  • 画像が保存できない
  • プラグインを追加できない

という問題が発生しました

結論、権限の問題だったらしく、下記の対応をすることによって解決できました🙏
※バックアップは必須だと思うので、その点はご注意を

# まずはwordpressの権限をnginxに変更。nginxで配信してるので、ここは適宜変更する必要有りかもです
sudo chown -R nginx:nginx magazine

sudo chmod 755 plugins
sudo chmod 755 uploads

参考記事

WordPress管理画面からプラグインがインストールできない問題

https://caramelcase.com/wordpress-aws-ec2-nginx-php7-mysql/