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

issue serving on offline laptop #1

Closed
n0manarmy opened this issue May 23, 2020 · 4 comments
Closed

issue serving on offline laptop #1

n0manarmy opened this issue May 23, 2020 · 4 comments

Comments

@n0manarmy
Copy link

n0manarmy commented May 23, 2020

I ran through the quick-start development-laptop server directions for release 0.1.2 binary, only configured the .cargo/config variable to redirect to localhost.

I've downloaded the entire crate library and am now running

romt serve -v

and I get the below error

Rewrite URL: /git/crates.io-index/info/refs?service=git-upload-pack -> /cgi-bin/git-http-backend.py/crates.io-index/info/refs?service=git-upload-pack
127.0.0.1 - - [23/May/2020 09:07:50] "GET /git/crates.io-index/info/refs?service=git-upload-pack HTTP/1.1" 200 -
127.0.0.1 - - [23/May/2020 09:07:50] command: /usr/bin/romt -u /opt/romt/mirror/cgi-bin/git-http-backend.py
127.0.0.1 - - [23/May/2020 09:07:50] b"usage: romt [-h] [--version] [-v] [-q] [--readme]\n            {crate,rustup,toolchain,serve} ...\nromt: error: argument subparser_name: invalid choice: '/opt/romt/mirror/cgi-bin/git-http-backend.py' (choose from 'crate', 'rustup', 'toolchain', 'serve')\n"
127.0.0.1 - - [23/May/2020 09:07:50] CGI script exit status 0x2

when I run

romt -u

I get the below error

usage: romt [-h] [--version] [-v] [-q] [--readme]
            {crate,rustup,toolchain,serve} ...
romt: error: unrecognized arguments: -u

I'm not sure if I'm doing something wrong. I wanted to post this first before digging into the code, cause usually its operator error.
My env is ubuntu 20.02

@drmikehenry
Copy link
Owner

Hi, @n0manarmy,

Thanks for the bug report. I am able to reproduce your results using the pre-built executable. Most of my testing was done by installing the Romt source into a virtual environment. I did not test the PyInstaller-generated executable version of Romt exhaustively, and apparently I didn't try a git clone operation with romt serve. Romt uses the HTTP server built into Python's httpmodule, which supports two kinds of CGI scripts. The first is a general executable file stored in cgi-bin/, and the second is a Python source file (ending in .py). For the latter, the http module uses sys.executable to spawn another copy of the Python interpreter for running the .py file. Unfortunately, this fails when the Python script is built into an executable using PyInstaller, since sys.executable in that case is the PyInstaller-generated executable instead of the Python interpreter (/usr/bin/romt in your case, instead of /usr/bin/python).

Since you are on Linux, the quickest fix is to remove the generated cgi-bin/git-http-backend.py script and copy the git-http-backend executable directly into cgi-bin/:

rm cgi-bin/git-http-backend.py
cp /usr/lib/git-core/git-http-backend cgi-bin/

On Linux, git-http-backend will run successfully after being copied into another directory. On Windows, git-http-backend.exe fails to run when copied into another directory unless a large number of .dll files are copied as well, so a different work-around would be needed.

Alternatively on Linux, you could replace the cgi-bin/git-http-backend.py script with a shell script cgi-bin/git-http-backend having contents:

#!/bin/sh
exec /usr/lib/git-core/git-http-backend

After chmod +x cgi-bin/git-http-backend, it should work as well without having to copy the entire git-http-backend executable into cgi-bin/.

Currently I don't have a nice work-around for Windows users who may be reading this ticket. I think copying git-http-backend.exe and all associated `.dll`` files should work, but I haven't tested that.

I'll look into a way to fix the problem more neatly. Sorry for the speed bump; hopefully this work-around will get you running successfully.

@n0manarmy
Copy link
Author

That worked perfectly! Thank you!! I appreciate your effort with this application! This is a big help for a lot of my dev efforts when I'm working offline.

@drmikehenry
Copy link
Owner

I'm glad to hear it's working for you now. I think I'll leave this issue open until I've implemented a better fix, in case someone else runs into the same issue.

@drmikehenry drmikehenry reopened this May 24, 2020
@drmikehenry
Copy link
Owner

Version v0.1.3 provides a fix for romt serve failures using the PyInstaller-built executables.

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

No branches or pull requests

2 participants