Closed azamat-sharapov closed 8 years ago
Can you try to run teamocil --debug layout_name
and paste the output?
Also, pasting the content of the layout (YAML file) youβre trying to run would help :smile:
π @remiprev,
Thanks for maintaining this gem. I β€οΈ teamocil.
I ran into the same issue as the op.
Running teamocil --here layout_name
raises an exception with the following stacktrace:
/Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/window.rb:36:in `block in as_tmux': undefined method `internal_index' for nil:NilClass (NoMethodError)
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/window.rb:32:in `tap'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/window.rb:32:in `as_tmux'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/session.rb:21:in `map'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/session.rb:21:in `block in as_tmux'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/session.rb:19:in `tap'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/tmux/session.rb:19:in `as_tmux'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/layout.rb:37:in `shell_commands'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/layout.rb:7:in `execute!'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/lib/teamocil/cli.rb:21:in `run!'
from /Users/rewinfrey/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/teamocil-1.4/bin/teamocil:7:in `<top (required)>'
from /Users/rewinfrey/.rbenv/versions/2.2.3/bin/teamocil:23:in `load'
from /Users/rewinfrey/.rbenv/versions/2.2.3/bin/teamocil:23:in `<main>'
The output of teamocil --debug layout_name
is (the layout is called project
):
tmux rename-session 'project'
tmux new-window -c '/Users/rewinfrey/project'
tmux select-pane -t .0
tmux new-window -n 'zeus'
tmux send-keys -t 'zeus.0' 'bin/zeus start'
tmux send-keys -t 'zeus.0' 'Enter'
tmux select-layout -t 'zeus' 'even-vertical'
tmux select-pane -t zeus.0
tmux new-window -n 'console'
tmux send-keys -t 'console.0' 'bin/console'
tmux send-keys -t 'console.0' 'Enter'
tmux select-layout -t 'console' 'even-vertical'
tmux select-pane -t console.0
tmux new-window -n 'vim'
tmux send-keys -t 'vim.0' 'vim'
tmux send-keys -t 'vim.0' 'Enter'
tmux select-layout -t 'vim' 'even-vertical'
tmux select-pane -t vim.0
And the contents of the layout file:
name: "project"
windows:
- root: /Users/rewinfrey/project
- name: zeus
layout: even-vertical
panes:
- commands:
- bin/zeus start
- name: console
layout: even-vertical
panes:
- commands:
- bin/console
- name: vim
layout: even-vertical
panes:
- commands:
- vim
Other relevant info:
teamocil 1.4 Ruby 2.2.3 tmux 2.1
I also confirmed that I have only one version of teamocil installed (1.4).
I noticed that there is a difference in the Teamocil::Tmux::Window
from the tagged v.1.4 and what is currently in master, but both define Teamocil::VERSION = 1.4
. Is what is currently in master not reflected in the gem version available via rubygems that might solve this problem?
Thanks for your work on this! It is one of my favorite tools for my daily work flow. β€οΈ π
Ah, I figured out what the problem was.
In my layout file, I misunderstood root
to be a top level option for specifying the root of all windows, rather than a window level option. The root
included as a top level option was being parsed as a window and instantiated as a Teamocil::Tmux::Window
object. The problem arises because no panes
are specified for the erroneous root
window, so the Teamocil::Tmux::Window
object's panes
defaults to an empty array. The exception arises because panes.first
retuns nil
, and the code tries to call internal_index
on nil
, causing the undefined method 'internal_index' for nil:NilClass (NoMethodError)
.
Turns out, I just didn't read the documentation correctly π After updating my layout file so the root
option is specified per window, all is well:
name: "project"
windows:
- name: zeus
root: /Users/rewinfrey/project
layout: even-vertical
panes:
- commands:
- bin/zeus start
- name: console
root: /Users/rewinfrey/project
layout: even-vertical
panes:
- commands:
- bin/console
- name: vim
root: /Users/rewinfrey/project
layout: even-vertical
panes:
- commands:
- vim
All clear now! Sorry for the issue spam. Thanks again! π
Glad you solved the issue by yourself! π
The exception arises because
panes.first
retunsnil
, and the code tries to callinternal_index
onnil
, causing theundefined method 'internal_index' for nil:NilClass (NoMethodError)
.
Well I guess we should handle this case and treat a window without panes as blank window. What do you think?
Well I guess we should handle this case and treat a window without panes as blank window.
Sounds good to me! Thank you π
When I start teamocil with
--here
option, I get this error:tmux version 1.8, teamocil 1.2