Skip to content

Conversation

erikw
Copy link

@erikw erikw commented May 2, 2023

When using the latest version of this plugin on macOS, with a test directive in the dotbot installation configuration like

- ifmacos:
    - shell:
        - echo "is mac!"

Running the ./install in my dotfiles repo gives:

[...]
Traceback (most recent call last):
  File "/Users/dotman/dotfiles/.local/repos/dotbot/bin/dotbot", line 45, in <module>
    main()
  File "/Users/dotman/dotfiles/.local/repos/dotbot/bin/dotbot", line 42, in main
    dotbot.cli.main()
  File "/Users/dotman/dotfiles/.local/repos/dotbot/dotbot/cli.py", line 133, in main
    plugins.extend(module.load(abspath))
                   ^^^^^^^^^^^^^^^^^^^^
  File "/Users/dotman/dotfiles/.local/repos/dotbot/dotbot/util/module.py", line 13, in load
    loaded_module = load_module(module_name, path)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dotman/dotfiles/.local/repos/dotbot/dotbot/util/module.py", line 32, in load_module
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/dotman/dotfiles/.local/repos/dotbot-plugins/ifplatform/ifplatform.py", line 23, in <module>
    import distro
ModuleNotFoundError: No module named 'distro'

I set a pdb breakpoint right before the import at

import distro

and inspect sys.path and can see that it indeed contains the added entry ifplatform/lib/distro

['/Users/dotman/dotfiles/.local/repos/dotbot-plugins/ifplatform/lib/distro', '/Users/dotman/dotfiles/.local/repos/dotbot', '/Users/dotman/dotfiles/.local/repos/dotbot/lib/pyyaml/lib3', '/Users/dotman/dotfiles/.local/repos/dotbot/bin', '/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python311.zip', '/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11', '/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload', '/usr/local/lib/python3.11/site-packages']

I discovered though, that instead of adding lib/distro to sys.path adding lib/distro/src/distro did work!

With this change, the install script runs as expected

$ ./install
[...]
is mac!

@erikw
Copy link
Author

erikw commented May 2, 2023

Bug report (unrelated to this PR)

Unfortunately the issue tracker is not enabled on this repo, but I'd like to report an issue as well.

Using only this plugin, dotbot invoked as

"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" --plugin-dir ".local/repos/dotbot-plugins/ifplatform" "${@}"

and with a dotbot installation configuration containing only:

- shell:
  - echo test

then the shell command is executed 2 times instead of the expected 1!

$ ./install
echo test
All commands have been executed
echo test
All commands have been executed

==> All tasks executed successfully

Sure the install config should be idempotent, but it's not good that shell scripts that run slowly are run twice.

@erikw
Copy link
Author

erikw commented Feb 11, 2025

@ssbanerje could we merge this small PR that enables us to use this great plugin again in our dotfiles?

I see many forks of this repo use this fix already to get this plugin to work.

Thank you :-)

@ssbanerje ssbanerje merged commit 9394bb4 into ssbanerje:master Sep 12, 2025
@erikw erikw deleted the fix-module-import branch September 12, 2025 16:28
@erikw
Copy link
Author

erikw commented Sep 12, 2025

Awesome, thank you @ssbanerje !

@erikw erikw mentioned this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants