bench get-app --soft-link error
Issue: Bug report
Version: v5.x
bench get-app --soft-link /home/frappe/bench/my_folder/my_app
Got error when I tried to install app using --soft-link options.
Traceback (most recent call last):
File "/home/frappe/.local/bin/bench", line 8, in <module>
sys.exit(cli())
^^^^^
File "/home/frappe/.bench/bench/cli.py", line 132, in cli
bench_command()
File "/home/frappe/.local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/frappe/.local/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/frappe/.local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/frappe/.local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/frappe/.local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/frappe/.bench/bench/commands/make.py", line 167, in get_app
get_app(
File "/home/frappe/.bench/bench/app.py", line 385, in get_app
git_url = app.url
^^^^^^^
File "/home/frappe/.bench/bench/app.py", line 173, in url
return self.get_http_url()
^^^^^^^^^^^^^^^^^^^
File "/home/frappe/.bench/bench/app.py", line 176, in get_http_url
return f"https://{self.remote_server}/{self.org}/{self.repo}.git"
^^^^^^^^
AttributeError: 'App' object has no attribute 'org'
INFO: A newer version of bench is available: 5.19.0 → 5.24.1
Problems:
- The problems arise on
get_appfunction trying to getapp.url.
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L687
- It's because app class doesn't get set up properly.
App.on_disk should be true, but because of if not self.is_repo: force setup_details to exit too early.
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L86-L90
App.on_disk should be setup on elif os.path.exists(self.mount_path):
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L98-L100
- When tried to access
app.urlit'll tried to get url fromAppMeta.get_http_url()sinceApp.on_diskdoesn't get setup properly.
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L149-L155
App.get_http_url()will throw an error, since it shouldn't get called in the first place.
self.org is missing
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L159-L160
@pipech I can't reproduce this on the latest version, can you please share the output of bench --version
I see mine is old version 5.19.0, you could close the issues doesn't exist on latest version.
@pipech I can't reproduce this on the latest version, can you please share the output of
bench --version
bench get-app --soft-link /home/frappe/bench/my_folder/my_app
One thing, that folder to link shouldn't have git, please delete .git folder. (Sorry I forgot to mention the key important things.)
One thing, that folder to link shouldn't have git, please delete
.gitfolder. (Sorry I forgot to mention the key important things.)
@pipech what do you mean by that? Why shouldn't it be a git repository? We shouldn't be modifying the user's folder regardless.
No not modifying the user's folder, I mean when you try to reproduce the issues make sure that there are no .git folder inside that folder.
Normally there will be a .git folder in an app.
frappe@c02cf97fc2eb:~/bench/apps/erpnext$ ls -la
total 160
drwxr-xr-x 1 frappe frappe 4096 Oct 28 2024 .
drwxr-xr-x 1 frappe frappe 4096 May 7 16:23 ..
drwxr-xr-x 1 frappe frappe 4096 Oct 28 2024 erpnext
drwxr-xr-x 1 frappe frappe 4096 May 9 15:53 .git << HERE
Install with soft-link will throw an error if there aren't .git inside that folder.
My use case is I have a mono repo containing multiple apps, when I tired to install using soft-link it'll throw an error as mention above.
Ah okay, using the standard frappe app setup its fine, not sure about such a monorepo setup.
@akhilnarang
Not sure if you are missing the point.
--soft-link will failed if the folder doesn't have git.
If you don't plan to support folder with no git, why would you add --no-git support?
https://github.com/frappe/bench/blob/8fcbac066966ec8deabe4e8aa0ca021591a52810/bench/app.py#L87-L90
Ah got it @pipech, thanks for the clarification.
https://github.com/frappe/bench/pull/1629
This simple fix "should" fix the issues.