Accessing zsh environment variables from within a VS code dev container? - docker

I'm trying to access an environment variable that is exported in zsh on my OSX machine.
.zshrc:
...
export SOME_API_KEY=XXXXXXXXXXXXXXX
...
devcontainer.json:
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:3.11",
"containerEnv": {
"SOME_API_KEY": "${localEnv:SOME_API_KEY}"
}
}
main.py:
...
print(os.environ['SOME_API_KEY'])
...
Running the script in the container (yes, I rebuilt it) generates an error:
Traceback (most recent call last):
File "/workspaces/supreme-rat/main.py", line 21, in <module>
print(os.environ['SOME_API_KEY'])
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "<frozen os>", line 678, in __getitem__
KeyError: 'SOME_API_KEY'
What am I missing?

Related

Trouble Installing Frappe on Docker

As I have stated in the title, I'm having trouble installng Frappe/ERPNext on my Docker. I followed instructions from their official Github repo here.
After opening frappe_docker folder in VSCode, when trying to execute the bench init command I got an error. Below are the full code:
frappe#84badc593d50:/workspace/development$ bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench
Traceback (most recent call last):
File "/home/frappe/.bench/bench/commands/make.py", line 68, in init
init(
File "/home/frappe/.bench/bench/utils/render.py", line 105, in wrapper_fn
return fn(*args, **kwargs)
File "/home/frappe/.bench/bench/utils/system.py", line 63, in init
bench.setup.dirs()
File "/home/frappe/.bench/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/home/frappe/.bench/bench/bench.py", line 337, in dirs
os.makedirs(self.bench.name, exist_ok=True)
File "/home/frappe/.pyenv/versions/3.10.5/lib/python3.10/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'frappe-bench'
I have had user added to docker group as per instruction and have followed it step by step but I got the error above. I've tried run chmod -R frappe:frappe * at the frappe folder but the error still persist.
My machine is running Pop!_OS 20.04 and Docker Desktop 4.16.1
My bad guys, I found the answer.
All I need to do was run chown frappe:frappe /workspace/development/ and all is well. I can run bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench without a problem after that.

Docker: error using docker-compose up on the official getting started tutorial

I'm new to docker and I'm trying to follow this simple "getting started" tutorial https://docs.docker.com/compose/gettingstarted/ using a newly first time installation of docker (for Windows 10) dowloaded from here: https://hub.docker.com/editions/community/docker-ce-desktop-windows/.
At step 4 of this tutorial i get this error:
PS D:\composetest> docker-compose up
Building web
Traceback (most recent call last):
File "site-packages\docker\credentials\store.py", line 80, in _execute
File "subprocess.py", line 395, in check_output
File "subprocess.py", line 487, in run
subprocess.CalledProcessError: Command '['C:\\Program Files\\Docker\\Docker\\resources\\bin\\docker-credential-desktop.EXE', 'list']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose\cli\main.py", line 72, in main
File "compose\cli\main.py", line 128, in perform_command
File "compose\cli\main.py", line 1078, in up
File "compose\cli\main.py", line 1074, in up
File "compose\project.py", line 548, in up
File "compose\service.py", line 367, in ensure_image_exists
File "compose\service.py", line 1106, in build
File "site-packages\docker\api\build.py", line 261, in build
File "site-packages\docker\api\build.py", line 308, in _set_auth_headers
File "site-packages\docker\auth.py", line 302, in get_all_credentials
File "site-packages\docker\credentials\store.py", line 71, in list
File "site-packages\docker\credentials\store.py", line 93, in _execute
docker.credentials.errors.StoreError: Credentials store docker-credential-desktop exited with "error listing credentials - err: exit status 1, out: `Impossibile trovare elemento.`".
[13284] Failed to execute script docker-compose
EDIT: The accepted solution in docker-compose unable to start, unfortunately, did not work.
What is going wrong?
I have the same issue...
Try:
$nano ~/.docker/config.json
In this file change credsStore to credStore
Now run your docker-compose. If its not works try sudo
try to add to the environment path :
C:\Program Files\Docker\Docker\resources\bin
If you are using WSL2 run this command
sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe

How to invoke conan in docker container by jenkins? error Failed to execute script conan

Using Docker as a build environment, My jenkinsfile starting specified docker container and invoking CMake which trigger build process using conan and so on. Unfortunately pipeline failed with the following output:
-- Conan: checking conan executable
-- Conan: Found program /usr/bin/conan
-- Conan: Version found [148] Failed to execute script conan
Traceback (most recent call last):
File "conan/conans/conan.py", line 11, in <module>
File "conan/conans/conan.py", line 7, in run
File "conan/conans/client/command.py", line 2151, in main
File "conan/conans/client/conan_api.py", line 222, in factory
File "conan/conans/client/conan_api.py", line 234, in __init__
File "conan/conans/client/migrations.py", line 26, in __init__
File "conan/conans/client/cache/cache.py", line 78, in __init__
File "conan/conans/client/cache/cache.py", line 150, in config
File "conan/conans/util/files.py", line 190, in save
FileNotFoundError: [Errno 2] No such file or directory: '/.conan/conan.conf'
-- Conan executing: /usr/bin/conan install . -s build_type=Release -s compiler=clang -s compiler.version=10 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing
[176] Failed to execute script conan
Traceback (most recent call last):
I do not know what the problem is. If I start container and build it manually it works.
If I create it manually then I am getting following error:
Conan: Version found ERROR: Can't write version file in /.conan/version.txt
I added the following environment variable to my jenkinsfile. Then it simply works!. I was trying to define env variables in docker container that was my fail
environment {
CONAN_USER_HOME = "${env.WORKSPACE}/"
CONAN_NON_INTERACTIVE = 1
}

Error in making python2.7 file executable with official py2app instructions on a hello word program

OSX 10.14 (Mojave)
python 2.7
py2app version = most recent as of Feb 11th 2019
I follow the official instructions found here:
https://py2app.readthedocs.io/en/latest/tutorial.html
I'm trying to get it to make a standalone for a 'hello world' program.
Everything works until the last step, which is 'python setup.py py2app'. I get the following error:
"Traceback (most recent call last):
File "setup.py", line 18, in
setup_requires=['py2app'],"
I did not modify the contents of the setup.py file, so they are as follows"
#
from setuptools import setup
APP = ['appp.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
#
Note that prior to this last step, I did indeed run 'rm -rf build dist' as instructed.
The error that I get is:
Traceback (most recent call last):
File "setup.py", line 18, in
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/build_app.py", line 838, in run
self._run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/build_app.py", line 1053, in _run
self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/build_app.py", line 1150, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/build_app.py", line 1007, in process_recipes
rval = check(self, mf)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/recipes/six.py", line 113, in check
mf.import_hook(nm, m)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/modulegraph/modulegraph.py", line 1082, in import_hook
q, tail = self._find_head_package(parent, name, level)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/modulegraph/modulegraph.py", line 1182, in _find_head_package
raise ImportError("No module named " + qname)
ImportError: No module named gdbm

Dart VM fails to build on windows

I am trying to buiil Dart-VM on windows, I follow the steps as described here
https://github.com/dart-lang/sdk/wiki/Building
When I run the build.py command as below:
.\tools\build.py --mode release --arch x64 create_sdk
I get the following error:
gn gen --check in out\ReleaseX64
Traceback (most recent call last):
File "D:\ops\dart\sdk\tools\gn.py", line 436, in <module>
sys.exit(main(sys.argv))
File "D:\ops\dart\sdk\tools\gn.py", line 423, in main
results = pool.map(run_command, commands, chunksize=1)
File "C:\app\Python27\lib\multiprocessing\pool.py", line 251, in map
return self.map_async(func, iterable, chunksize).get()
File "C:\app\Python27\lib\multiprocessing\pool.py", line 567, in get
raise self._value
WindowsError: [Error 2] System cannot find file。
Tried to run GN, but it failed. Try running it manually:
$ python D:\ops\dart\sdk\tools\gn.py -m release -a x64 --os host -v
Traceback (most recent call last):
File "D:\ops\dart\sdk\tools\build.py", line 658, in <module>
sys.exit(Main())
File "D:\ops\dart\sdk\tools\build.py", line 651, in Main
mode, arch, cross_build) != 0:
File "D:\ops\dart\sdk\tools\build.py", line 491, in BuildOneConfig
args = BuildNinjaCommand(options, target, target_os, mode, arch)
File "D:\ops\dart\sdk\tools\build.py", line 473, in BuildNinjaCommand
if UseGoma(out_dir):
File "D:\ops\dart\sdk\tools\build.py", line 431, in UseGoma
return 'use_goma = true' in open(args_gn, 'r').read()
IOError: [Errno 2] No such file or directory: 'out\\ReleaseX64\\args.gn'
It seems missing the args.gn file in out\ReleaseX64 folder. but I cannot find args.gn in Dart source folders. Is it generated during building process? whether I do wrong steps led to no such file generated?

Resources