PreTeXtBook/pretext-cli

browser opening to wrong port

Alex-Jordan opened this issue · 3 comments

Today with CLI 2.2.0, I ran pretext view and I got:

Server will soon be available at http://localhost:8128
Opening browser for target `web` at http://localhost:8128/output/web in 3 seconds
warning: Port 8128 could not be used.
warning: Trying port 8129 instead.

Note that I do not know why 8128 could not be used.

Anyway then the web browser (Firefox) opened to http://localhost:8128/output/web and it was a 404. I edited the "8" to a "9" and I could see the book.

So it seems like if it moves to a new port, the new port is not being used by whatever pops open my browser.

So I think that I had earlier run pretext view from a different project, and a local web server was already going on 8128. That project did not have a web target. There, I named the target html. So when the browser went to 8128/output/web there was nothing there.

So that explains that but the real issue is that when 8128 was rejected and it moved on to spin up 8129, it should have used 8129 when opening my browser.

I'm working on the port issue right now.

Are you saying that "web" is hard coded?

I think there are two issues here. First, if for some non-pretext reason port 8128 is in use, then we were picking the next available port, but not reporting this back when displaying a message. This is fixed in #635 .

The other thing that can happen is that if you run a pretext view in one project, and then try to run a pretext view in a second project without closing the first project's server, pretext will assume that the server running for the first project will work for the second. I don't know a nice way to fix this, except that you can pass the -r flag to pretext view which will restart the currently running pretext server. For now, we will just suggest that this is what you should do if working with two projects at the same time.