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

MacOS: warning: An error occurred while redirecting file '/proc/1/cgroup' #295

Closed
Defman21 opened this issue Oct 6, 2022 · 26 comments · Fixed by #297
Closed

MacOS: warning: An error occurred while redirecting file '/proc/1/cgroup' #295

Defman21 opened this issue Oct 6, 2022 · 26 comments · Fixed by #297
Labels
🐛 bug something that doesn't works as expected

Comments

@Defman21
Copy link

Defman21 commented Oct 6, 2022

Env

Pure

4.1.2

Fish

fish, version 3.5.1

OS/distribution

macOS 12.6

My terminal looks like this 😞

image

@edouard-lopez
Copy link
Member

Thakns, that's a MacOS issue as there is no /proc/ in BSD-based OS.

I will fix asap, in the meanwhile could you edit $HOME/pure/functions/_pure_prompt_first_line.fish to:

-    set --local prompt_container (_pure_prompt_container)
+    set --local prompt_container ""

@externl
Copy link

externl commented Oct 6, 2022

I will fix asap, in the meanwhile could you edit $HOME/pure/functions/_pure_prompt_first_line.fish to:

$HOME/.config/fish/functions/_pure_prompt_first_line.fish

@edouard-lopez
Copy link
Member

@externl @Defman21 could you check it's fixed on 4.2.2.?

@externl
Copy link

externl commented Oct 6, 2022

 fisher install pure-fish/pure
fisher install version 4.4.2
Fetching https://api.github.com/repos/pure-fish/pure/tarball/HEAD
Installing pure-fish/pure
           /Users/joe/.config/fish/functions/_pure_check_for_new_release.fish
           /Users/joe/.config/fish/functions/_pure_detect_container_by_cgroup_method.fish
           /Users/joe/.config/fish/functions/_pure_detect_container_by_pid_method.fish
           /Users/joe/.config/fish/functions/_pure_format_time.fish
           /Users/joe/.config/fish/functions/_pure_get_prompt_symbol.fish
           /Users/joe/.config/fish/functions/_pure_is_inside_container.fish
           /Users/joe/.config/fish/functions/_pure_is_single_line_prompt.fish
           /Users/joe/.config/fish/functions/_pure_parse_directory.fish
           /Users/joe/.config/fish/functions/_pure_parse_git_branch.fish
           /Users/joe/.config/fish/functions/_pure_place_iterm2_prompt_mark.fish
           /Users/joe/.config/fish/functions/_pure_prefix_root_prompt.fish
           /Users/joe/.config/fish/functions/_pure_print_prompt.fish
           /Users/joe/.config/fish/functions/_pure_print_prompt_rows.fish
           /Users/joe/.config/fish/functions/_pure_prompt.fish
           /Users/joe/.config/fish/functions/_pure_prompt_beginning.fish
           /Users/joe/.config/fish/functions/_pure_prompt_command_duration.fish
           /Users/joe/.config/fish/functions/_pure_prompt_container.fish
           /Users/joe/.config/fish/functions/_pure_prompt_current_folder.fish
           /Users/joe/.config/fish/functions/_pure_prompt_ending.fish
           /Users/joe/.config/fish/functions/_pure_prompt_first_line.fish
           /Users/joe/.config/fish/functions/_pure_prompt_git.fish
           /Users/joe/.config/fish/functions/_pure_prompt_git_branch.fish
           /Users/joe/.config/fish/functions/_pure_prompt_git_dirty.fish
           /Users/joe/.config/fish/functions/_pure_prompt_git_pending_commits.fish
           /Users/joe/.config/fish/functions/_pure_prompt_git_stash.fish
           /Users/joe/.config/fish/functions/_pure_prompt_jobs.fish
           /Users/joe/.config/fish/functions/_pure_prompt_new_line.fish
           /Users/joe/.config/fish/functions/_pure_prompt_ssh.fish
           /Users/joe/.config/fish/functions/_pure_prompt_symbol.fish
           /Users/joe/.config/fish/functions/_pure_prompt_system_time.fish
           /Users/joe/.config/fish/functions/_pure_prompt_vimode.fish
           /Users/joe/.config/fish/functions/_pure_prompt_virtualenv.fish
           /Users/joe/.config/fish/functions/_pure_set_color.fish
           /Users/joe/.config/fish/functions/_pure_set_default.fish
           /Users/joe/.config/fish/functions/_pure_string_width.fish
           /Users/joe/.config/fish/functions/_pure_user_at_host.fish
           /Users/joe/.config/fish/functions/fish_greeting.fish
           /Users/joe/.config/fish/functions/fish_mode_prompt.fish
           /Users/joe/.config/fish/functions/fish_prompt.fish
           /Users/joe/.config/fish/functions/fish_title.fish
           /Users/joe/.config/fish/conf.d/_pure_init.fish
           /Users/joe/.config/fish/conf.d/pure.fish
Installed 1 plugin/s
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist

Still failing for me. Does fisher have a cache or anything?

@edouard-lopez
Copy link
Member

Can you gives me the output of:

OS

uname -s

Container detection

functions _pure_detect_container_by_pid_method

Pure version

echo $pure_version

@externl
Copy link

externl commented Oct 6, 2022

❯ uname -s
Darwin
❯ functions _pure_detect_container_by_pid_method
# Defined in /Users/joe/.config/fish/functions/_pure_detect_container_by_pid_method.fish @ line 1
function _pure_detect_container_by_pid_method --description 'Linux method to detect container using /proc. see https://stackoverflow.com/a/37015387/802365'

    set --query proc_sched[1]; or set proc_sched /proc/1/sched

    set --local os_name (uname -s)
    if test $os_name != "Darwin"
        head -n 1 $proc_sched \
            | string match \
            --quiet \
            --invert \
            --regex 'init|systemd'
    else
        set --local failure 1
        return $failure
    end
end
❯ echo $pure_version
4.2.2

@edouard-lopez
Copy link
Member

Could you reload the _pure_detect_container_by_pid_method?

source $HOME/.config/fish/functions/_pure_detect_container_by_pid_method.fish && _pure_detect_container_by_pid_method

Or your whole config:

source $HOME/.config/fish/config.fish

@externl
Copy link

externl commented Oct 6, 2022


warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist

I've also tried removing and re-adding. Each time with a new shell instance.

@externl
Copy link

externl commented Oct 6, 2022

I haven't looked too close at the logic, but

❯ if _pure_detect_container_by_pid_method; echo "true"; else; echo "false"; end
false

and _pure_detect_container_by_cgroup_method is the method throwing all the warnings. (I think)

@externl
Copy link

externl commented Oct 6, 2022

Looks like, _pure_is_inside_container is being called with an empty cgroup_namespace, which causes _pure_detect_container_by_cgroup_method to default to /proc/1/cgroup

@externl
Copy link

externl commented Oct 6, 2022

What is supposed to set proc_sched?

@Defman21
Copy link
Author

Defman21 commented Oct 6, 2022

I've tried to early return from both cgroup and pid functions (if test (uname -s) = "Darwin"; return 1; end) but my prompt looks like this:

image

I will fix asap, in the meanwhile could you edit $HOME/pure/functions/_pure_prompt_first_line.fish to:

$HOME/.config/fish/functions/_pure_prompt_first_line.fish

Applying this patch fixed the issue for me.

@Defman21
Copy link
Author

Defman21 commented Oct 6, 2022

There's an explicit echo in _pure_prompt_contanier:

image

Removing it and early returning from both cgroup and pid functions helped.

@edouard-lopez
Copy link
Member

edouard-lopez commented Oct 6, 2022

Please revert to previous version

fisher install pure-fish/pure@v4.1.0

@nertzy
Copy link

nertzy commented Oct 6, 2022

@edouard-lopez Didn't work for me

dev@olive /Users/dev > fisher install pure-fish/pure@v4.2.2
fisher install version 4.4.2
Fetching https://api.github.com/repos/pure-fish/pure/tarball/v4.2.2
Installing pure-fish/pure@v4.2.2
           /Users/dev/.config/fish/functions/_pure_check_for_new_release.fish
           /Users/dev/.config/fish/functions/_pure_detect_container_by_cgroup_method.fish
           /Users/dev/.config/fish/functions/_pure_detect_container_by_pid_method.fish
           /Users/dev/.config/fish/functions/_pure_format_time.fish
           /Users/dev/.config/fish/functions/_pure_get_prompt_symbol.fish
           /Users/dev/.config/fish/functions/_pure_is_inside_container.fish
           /Users/dev/.config/fish/functions/_pure_is_single_line_prompt.fish
           /Users/dev/.config/fish/functions/_pure_parse_directory.fish
           /Users/dev/.config/fish/functions/_pure_parse_git_branch.fish
           /Users/dev/.config/fish/functions/_pure_place_iterm2_prompt_mark.fish
           /Users/dev/.config/fish/functions/_pure_prefix_root_prompt.fish
           /Users/dev/.config/fish/functions/_pure_print_prompt.fish
           /Users/dev/.config/fish/functions/_pure_print_prompt_rows.fish
           /Users/dev/.config/fish/functions/_pure_prompt.fish
           /Users/dev/.config/fish/functions/_pure_prompt_beginning.fish
           /Users/dev/.config/fish/functions/_pure_prompt_command_duration.fish
           /Users/dev/.config/fish/functions/_pure_prompt_container.fish
           /Users/dev/.config/fish/functions/_pure_prompt_current_folder.fish
           /Users/dev/.config/fish/functions/_pure_prompt_ending.fish
           /Users/dev/.config/fish/functions/_pure_prompt_first_line.fish
           /Users/dev/.config/fish/functions/_pure_prompt_git.fish
           /Users/dev/.config/fish/functions/_pure_prompt_git_branch.fish
           /Users/dev/.config/fish/functions/_pure_prompt_git_dirty.fish
           /Users/dev/.config/fish/functions/_pure_prompt_git_pending_commits.fish
           /Users/dev/.config/fish/functions/_pure_prompt_git_stash.fish
           /Users/dev/.config/fish/functions/_pure_prompt_jobs.fish
           /Users/dev/.config/fish/functions/_pure_prompt_new_line.fish
           /Users/dev/.config/fish/functions/_pure_prompt_ssh.fish
           /Users/dev/.config/fish/functions/_pure_prompt_symbol.fish
           /Users/dev/.config/fish/functions/_pure_prompt_system_time.fish
           /Users/dev/.config/fish/functions/_pure_prompt_vimode.fish
           /Users/dev/.config/fish/functions/_pure_prompt_virtualenv.fish
           /Users/dev/.config/fish/functions/_pure_set_color.fish
           /Users/dev/.config/fish/functions/_pure_set_default.fish
           /Users/dev/.config/fish/functions/_pure_string_width.fish
           /Users/dev/.config/fish/functions/_pure_user_at_host.fish
           /Users/dev/.config/fish/functions/fish_greeting.fish
           /Users/dev/.config/fish/functions/fish_mode_prompt.fish
           /Users/dev/.config/fish/functions/fish_prompt.fish
           /Users/dev/.config/fish/functions/fish_title.fish
           /Users/dev/.config/fish/conf.d/_pure_init.fish
           /Users/dev/.config/fish/conf.d/pure.fish
Installed 1 plugin/s
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
~ _pure_is_inside_container 1
❯ warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
~ _pure_is_inside_container 1
❯ warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
~ _pure_is_inside_container 1
❯ warning: An error occurred while redirecting file '/proc/1/cgroup'
warning: Path '/proc' does not exist
warning: An error occurred while redirecting file '/proc/1/cgroup'
~ _pure_is_inside_container 1
❯

@externl
Copy link

externl commented Oct 6, 2022

fisher install pure-fish/pure@v4.2.2

This is currently the latest version. Did you mean 4.1.0?

@Defman21
Copy link
Author

Defman21 commented Oct 6, 2022

I'll just stick to my patches and wait for the fix. I could send a PR with Darwin returns and the removal of echo since it's working for me if you want @edouard-lopez

@edouard-lopez
Copy link
Member

You can try the code form #298. Regarding MacOS, as I don't have a Mac to test directly I'm going a bit blind despite the tests (CI job for MacOS has numerous errors).

To try it locally, you need to

git clone git@github.com:pure-fish/pure.git
# manually
git fetch origin fix/macos-container-detection-error
git switch fix/macos-container-detection-error

# or with gh CLI
gh pr checkout 298

Then install it:

cd <pure-directory>
fisher remove pure-fish/pure
fisher install ./

@edouard-lopez edouard-lopez reopened this Oct 6, 2022
@nertzy
Copy link

nertzy commented Oct 6, 2022

Yes, installing PR 298 is working for me!

@Defman21
Copy link
Author

Defman21 commented Oct 6, 2022

PR 298 is working for me too.

@externl
Copy link

externl commented Oct 6, 2022

#298 works for me as well!

@orf
Copy link
Contributor

orf commented Oct 7, 2022

fisher install pure-fish/pure@fix/macos-container-detection-error

works for me!

@edouard-lopez
Copy link
Member

4.2.3 is released! 🎉

@edouard-lopez edouard-lopez changed the title warning: An error occurred while redirecting file '/proc/1/cgroup' MacOS: warning: An error occurred while redirecting file '/proc/1/cgroup' Oct 10, 2022
@edouard-lopez edouard-lopez added the 🐛 bug something that doesn't works as expected label Oct 10, 2022
@mizzunet
Copy link

mizzunet commented Aug 9, 2023

This issue occurs on Termux as well. Because it doesn't have access to /proc. set --local prompt_container "" workaround works :)

@edouard-lopez
Copy link
Member

@mizzunet There is a flag to disable container detection (see https://github.com/pure-fish/pure/releases/tag/v4.3.0)

set --universal pure_enable_container_detection false

To get support for Android OS, please open a new issue and provide the result for uname -a on your device?
The code that manage container detection is https://github.com/pure-fish/pure/blob/master/functions/_pure_is_inside_container.fish#L12-L22

@mizzunet
Copy link

@edouard-lopez

To get support for Android OS, please open a new issue and provide the result for uname -a on your device?

This Termux doesn't have access to /proc. So, I think the proper solution is to disable this container detection beforehand if it cannot have access to /proc, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug something that doesn't works as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants