Runtime.txt does not work if base directory is not root

Briefly summarize the issues you have been experiencing.

I want to use python 3.7. I have a runtime.txt in the root of my folder. My base directory is ./documentation.

This runtime.txt has no effect.

7:06:04 PM: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.

Please provide a link to your live site hosted on Netlify

https://test-elegant.netlify.com/

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?

I tried moving the runtime.txt file inside the documentation folder. But then the build completely fails.

The log of the failed build are here.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?

  1. Moving runtime.txt inside base folder kills the build prematurely
  2. Keep runtime.txt in the root outside base folder has no effect at all

In my other site hosted on Netlify, runtime.txt is in the root and base directory is also the root. In which case I am able to run Python 3.7.

Hi,

You’re right, some files, like the netlify.toml and runtime.txt need to be in the root of your repo. Sorry about the lack of documentation! We’ll work on that.

Thank you @futuregerald. But even when I have runtime.txt in the root, it does not work.

If you see the logs here, you can see

7:06:04 PM: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.

even though, as you can see, runtime.txt is in the root.

This is how I fixed the issue.

  1. I kept base directory root
  2. In the build command I added cd i.e. cd documentation && make publish-netlify
  3. I set the publish folder to ./documentation/output

It fixed the issue.

Hi @talha131, you may have better reliability with your python install if you use the Trusty build image instead of Xenial. I’m not sure what you’re doing in the publish-netlify script but I’m glad you found a solution.

Today we reviewed this situation with our documentation team and discovered a few things:

  1. I think Gerald’s assertion about runtime.txt in the root was wrong - you do indeed need it in the base directory and that worked in my tests on both build images.
  2. since we never saw your build logs as to what this looked like:
  1. Moving runtime.txt inside base folder kills the build prematurely

…it’s a bit hard to speculate as to what happened. In my tests, that did not happen (basedir/runtime.txt contained the string 3.5 and my build logs showed:

10:42:05 AM: Python version set to 3.5

and the build completed as usual. If you wanted we’d be happy to take a look at some failed build logs to help track down that problem?

1 Like

Thanks a lot @fool, I tried again with following configuration and it worked.

[build]
  base = "./documentation"
  publish = "./documentation/output"
  command = "make publish-netlify"

Netlify recognizes the runtime.txt and requirements.txt inside the base folder.

I have deleted my test repository and I cannot recall the configuration that was causing it to fail.