Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to restore grunt #32

Closed
johnnncodes opened this issue Aug 31, 2014 · 11 comments
Closed

Not able to restore grunt #32

johnnncodes opened this issue Aug 31, 2014 · 11 comments

Comments

@johnnncodes
Copy link

Should run grunt using "grunt development"

I'm using this setting in .tmux.conf: set -g @resurrect-processes ':all:'

This is the output in the console when resurrecting:

grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-Ou97Qf/Render
➜ pdm git:(master) ✗ grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-Ou97Qf/Render
Warning: Task "ARCHFLAGS=-arch" not found. Use --force to continue.

@bruno-
Copy link
Member

bruno- commented Aug 31, 2014

Hi, thanks for reporting the issue. This is a bug and I don't know how to handle it for now.

To clarify:

  1. this is the command you run: grunt development
  2. when saving tmux environment, this is saved: grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-Ou97Qf/Render

Weird env variables ARCHFLAGS and Apple_PubSub... are fine, we could remove them.
Unfortunately I don't see the word development in there, so that information is lost and can't be restored.

Thinking about other solutions to handle this, we could have a user option like this:

set -g @some-tmux-option "grunt->grunt development"

The above states: to restore grunt, the command to restore it is grunt development.
Would having that feature help?

@johnnncodes
Copy link
Author

Hi @bruno- , yes I think having that feature would help. Anyway, I thought a feature that is almost similar to that already exists? I saw this in the docs:

set -g @resurrect-processes 'some_program "git log"'

and

set -g @resurrect-processes 'irb pry "~rails server" "~rails console"'

I also tried them btw but it didn't solved the issue. There was no output unlike the setting I used on my 1st comment - #32 (comment)

set -g @resurrect-processes '"grunt development"'

and

set -g @resurrect-processes '"~grunt development"'

@bruno-
Copy link
Member

bruno- commented Sep 1, 2014

Yea, those features are similar, but not really what we need here.

Okay, I'll work on a feature that will hopefully help with this and then let you know.

@bruno-
Copy link
Member

bruno- commented Sep 1, 2014

Hi, this feature should now be implemented.
So you can:

  • update the plugin (prefix + U if you have tpm installed)

  • set the following option (pls take care of quoting, single quotes outside, double quotes "inside"):

     set -g @resurrect-processes '"grunt->grunt development"'
    

Now, when grunt program is restored, the plugin will invoke grunt development command.

Let me know if it works!

@hoschi
Copy link

hoschi commented Sep 7, 2014

Have you tried save/restore the whole command instead of the process? Grunt is a bad example because it eats up the arguments. git log develop -20 gets restarted as git log instead. When you use the command you can restore the exact thing you started before. You get the command by ps --pid $pane_pid -o cmd. For grunt, someone can easily use a simple wrapper script, e.g.:

#! /bin/sh

grunt $*

@bruno-
Copy link
Member

bruno- commented Sep 7, 2014

I just tested the command git log master -20 command and it got both saved and restored properly with all the arguments.

I'd love to improve the "process" for saving commands! Currently this is pretty isolated in this function here. I encourage you to submit a pull request that improves on that. Also feel free to ask related questions if there's any.

@johnnncodes
Copy link
Author

@bruno- For some reason, it still doesn't work. Here's the contents of ~/.tmux/resurrect/last:

pane    0   0   :node   1   :*  0   :/Users/johnkevinmbasco/Vagrant/salt_basic/bitlock-angular  1   node    :grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-RoJZ9c/Render
window  0   0   1   :*  c8bd,156x37,0,0,0
state   0

Here's my tmux.conf:

# List of plugins
# Supports `github_username/repo` or full git URLs
set -g @tpm_plugins "              \
  tmux-plugins/tpm                 \
  tmux-plugins/tmux-sensible       \
  tmux-plugins/tmux-resurrect      \
"
set -g @resurrect-processes '"grunt->grunt development"'

# initializes TMUX plugin manager
run-shell ~/.tmux/plugins/tpm/tpm

setw -g mode-keys vi

bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

set -g default-terminal "xterm"

@hoschi
Copy link

hoschi commented Sep 13, 2014

I just tested the command git log master -20 command and it got both saved and restored properly with all the arguments.

It doesn't work here :( I created a new issue #43

@bruno-
Copy link
Member

bruno- commented Sep 13, 2014

@basco-johnkevin thanks for the patience with this.
Your .tmux.conf looks fine.
I tested restoring the state with the content of ~/.tmux/resurrect/last you provided and grunt also wasn't restoring for me!

After a while, I realized what's the problem:

  • when you kill tmux server and start it again, tmux opens session 0 with window 0 by default
  • now when you try to restore saved environment, tmux-restore will not restore session 0 and window 0 because it is already created! It also won't restore programs in that window - and this is why 'grunt' is not restored.

The above is actually considered to be a feature that makes tmux-resurrect idempotent. You can hit "tmux restore key" multiple times in the same tmux session, but the restore will happen only the first time.

Here are the steps to solve the problem and test if grunt is restoring properly:

  • run grunt program in any pane except in 'session 0/window 0'
  • save tmux environment
  • kill tmux
  • start tmux and restore the last environment

Hopefully it works for you now!

@bruno-
Copy link
Member

bruno- commented Sep 29, 2014

Any updates on this @basco-johnkevin ?
It should work now!

@bruno-
Copy link
Member

bruno- commented Oct 20, 2014

Hey guys, I'm doing a small issues cleanup. This feature seems to work now, please reopen or report again if you find any issues.

@bruno- bruno- closed this as completed Oct 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants