Pre-commit causing the following error when trying to commit locally - ruby-on-rails

I am working on a project and am required to use pre-commit.
After making a small code change, I tried to commit the change (in my local git repo). I got the following error:
dmk#DESKTOP-I1DLS2O:~/Markus$ git commit -m "Removed Grouping#marking_completed?"
[INFO] Installing environment for https://github.com/rubocop/rubocop.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
Check the log at /home/dmk/.cache/pre-commit/pre-commit.log
Here is the log:
version information
pre-commit version: 2.19.0
git --version: git version 2.25.1
sys.version:
3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux
error information
An unexpected error has occurred: CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/usr/local/lib/python3.8/dist-packages/pre_commit/main.py", line 361, in main
return hook_impl(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/commands/hook_impl.py", line 238, in hook_impl
return retv | run(config, store, ns)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/commands/run.py", line 414, in run
install_hook_envs(to_install, store)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/repository.py", line 223, in install_hook_envs
_hook_install(hook)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/repository.py", line 79, in _hook_install
lang.install_environment(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/languages/ruby.py", line 133, in install_environment
helpers.run_setup_cmd(
File "/usr/local/lib/python3.8/dist-packages/pre_commit/languages/helpers.py", line 51, in run_setup_cmd
cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/pre_commit/util.py", line 146, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('gem', 'build', 'rubocop.gemspec')
return code: 1
expected return code: 0
stdout:
Executable `ruby` not found
stderr: (none)
Other information:
I am working on a Rails project.
I am using WSL 2.
I am using Docker.
Please let me know if you require any other information.

it appears that your linux installation does not have a ruby executable (which pre-commit currently requires when language_version is not specified for language: ruby hooks)
you can install one on ubuntu/debian via sudo apt install ruby-dev
disclaimer: I created pre-commit

Related

OpenCV.js custom build failed in windows machine

I am trying to build opencv.js by following the steps mentioned in the Open CV [official document][1].
Note: I am trying to make a custom build instead of using the existing [opencv.js][2] library because I want to add some contrib modules as well.
Open CV source version: 4.5.1
Cmake: 3.20.0
Python: 3.7
Emscriptem: [latest][3]
operating system: windows 64 bit
The below is the stack trace of the issue I get when I try to execute the below command in the windows power shell..
emcmake python ./opencv/platforms/js/build_js.py build_js
Stack Trace
emcmake python ./opencv/platforms/js/build_js.py build_js
configure: python ./opencv/platforms/js/build_js.py build_js
Args: Namespace(build_dir='build_js', build_doc=False, build_flags=None, build_loader=False, build_perf=False, build_test=False, build_wasm=False, build_wasm_intrin_test=False, clean_build_dir=False, cmake_option=None, config='D:\\business\\Drapezy\\codetrials\\opencvjs\\opencv\\platforms\\js\\opencv_js.config.py', config_only=False, disable_wasm=False, emscripten_dir='D:\\business\\Drapezy\\codetrials\\opencvjs\\emsdk\\upstream\\emscripten', enable_exception=False, opencv_dir='D:\\business\\Drapezy\\codetrials\\opencvjs\\opencv', simd=False, skip_config=False, threads=False)
Check dir D:\business\Drapezy\codetrials\opencvjs\build_js (create: True, clean: False)
Check dir D:\business\Drapezy\codetrials\opencvjs\opencv (create: False, clean: False)
Check dir D:\business\Drapezy\codetrials\opencvjs\emsdk\upstream\emscripten (create: False, clean: False)
=====
===== Config OpenCV.js build for default target
=====
Executing: ['cmake', '-DPYTHON_DEFAULT_EXECUTABLE=C:\\Users\\girir\\AppData\\Local\\Programs\\Python\\Python37\\python.exe', '-DENABLE_PIC=FALSE', '-DCMAKE_BUILD_TYPE=Release', "-DCMAKE_TOOLCHAIN_FILE='D:\\business\\Drapezy\\codetrials\\opencvjs\\emsdk\\upstream\\emscripten\\cmake\\Modules\\Platform\\Emscripten.cmake'", "-DCPU_BASELINE=''", "-DCPU_DISPATCH=''", '-DCV_TRACE=OFF', '-DBUILD_SHARED_LIBS=OFF', '-DWITH_1394=OFF', '-DWITH_ADE=OFF', '-DWITH_VTK=OFF', '-DWITH_EIGEN=OFF', '-DWITH_FFMPEG=OFF', '-DWITH_GSTREAMER=OFF', '-DWITH_GTK=OFF', '-DWITH_GTK_2_X=OFF', '-DWITH_IPP=OFF', '-DWITH_JASPER=OFF', '-DWITH_JPEG=OFF', '-DWITH_WEBP=OFF', '-DWITH_OPENEXR=OFF', '-DWITH_OPENGL=OFF', '-DWITH_OPENVX=OFF', '-DWITH_OPENNI=OFF', '-DWITH_OPENNI2=OFF', '-DWITH_PNG=OFF', '-DWITH_TBB=OFF', '-DWITH_TIFF=OFF', '-DWITH_V4L=OFF', '-DWITH_OPENCL=OFF', '-DWITH_OPENCL_SVM=OFF', '-DWITH_OPENCLAMDFFT=OFF', '-DWITH_OPENCLAMDBLAS=OFF', '-DWITH_GPHOTO2=OFF', '-DWITH_LAPACK=OFF', '-DWITH_ITT=OFF', '-DWITH_QUIRC=ON', '-DBUILD_ZLIB=ON', '-DBUILD_opencv_apps=OFF', '-DBUILD_opencv_calib3d=ON', '-DBUILD_opencv_dnn=ON', '-DBUILD_opencv_features2d=ON', '-DBUILD_opencv_flann=ON', '-DBUILD_opencv_gapi=OFF', '-DBUILD_opencv_ml=OFF', '-DBUILD_opencv_photo=ON', '-DBUILD_opencv_imgcodecs=OFF', '-DBUILD_opencv_shape_transformer=ON', '-DBUILD_opencv_videoio=OFF', '-DBUILD_opencv_videostab=OFF', '-DBUILD_opencv_highgui=OFF', '-DBUILD_opencv_superres=OFF', '-DBUILD_opencv_stitching=OFF', '-DBUILD_opencv_java=OFF', '-DBUILD_opencv_js=ON', '-DBUILD_opencv_python2=OFF', '-DBUILD_opencv_python3=OFF', '-DBUILD_EXAMPLES=OFF', '-DBUILD_PACKAGE=OFF', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_DOCS=OFF', '-DWITH_PTHREADS_PF=OFF', '-DCV_ENABLE_INTRINSICS=OFF', '-DBUILD_WASM_INTRIN_TESTS=OFF', "-DCMAKE_C_FLAGS='-s USE_PTHREADS=0 '", "-DCMAKE_CXX_FLAGS='-s USE_PTHREADS=0 '", 'D:\\business\\Drapezy\\codetrials\\opencvjs\\opencv']
Re-run cmake no build system arguments
-- Detected processor: x86
-- Looking for ccache - not found
CMake Error at cmake/OpenCVCompilerOptimizations.cmake:593 (message):
Compiler doesn't support baseline optimization flags:
Call Stack (most recent call first):
cmake/OpenCVCompilerOptions.cmake:311 (ocv_compiler_optimization_options)
CMakeLists.txt:617 (include)
-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
File "./opencv/platforms/js/build_js.py", line 279, in <module>
File "./opencv/platforms/js/build_js.py", line 192, in config
File "./opencv/platforms/js/build_js.py", line 23, in execute
__main__.Fail: Child returned: 1
[1]: https://docs.opencv.org/master/d4/da1/tutorial_js_setup.html
[2]: https://docs.opencv.org/master/opencv.js
[3]: https://emscripten.org/docs/getting_started/downloads.html
Any ideas to resolve this issue is appreciated.
Building opencv.js on Windows will NOT work, at least according to this open issue. An alternative is to install WSL and use it to build.

An error happen during Bazel build: no such package '#cc//': Not a regular file:

I just upgrade mac OS to macOS Big Sur (11), it is no issue to reinstall drake from source (./setup/mac/install_prereqs.sh). But some errors happen during "bazel built".
The message is posted below:
MacBook-Pro examples % bazel test ...
INFO: Repository cc instantiated at:
/Users/wc/drake/WORKSPACE:10:22: in <toplevel>
/Users/wc/drake/tools/workspace/default.bzl:311:29: in add_default_workspace
/Users/wc/drake/tools/workspace/default.bzl:110:22: in add_default_repositories
Repository rule cc_repository defined at:
/Users/wc/drake/tools/workspace/cc/repository.bzl:161:32: in <toplevel>
ERROR: An error occurred during the fetch of repository 'cc':
Traceback (most recent call last):
File "/Users/wc/drake/tools/workspace/cc/repository.bzl", line 58, column 33, in _impl
cc = repository_ctx.path(Label("#local_config_cc//:wrapped_clang"))
Error in path: Not a regular file: /private/var/tmp/_bazel_wc/ecfb0aaf3c5988894c5be550fe9d5e24/external/local_config_cc/wrapped_clang
ERROR: Error fetching repository: Traceback (most recent call last):
File "/Users/wc/drake/tools/workspace/cc/repository.bzl", line 58, column 33, in _impl
cc = repository_ctx.path(Label("#local_config_cc//:wrapped_clang"))
Error in path: Not a regular file: /private/var/tmp/_bazel_wc/ecfb0aaf3c5988894c5be550fe9d5e24/external/local_config_cc/wrapped_clang
INFO: Repository rules_python instantiated at:
/Users/wc/drake/WORKSPACE:10:22: in <toplevel>
/Users/wc/drake/tools/workspace/default.bzl:311:29: in add_default_workspace
/Users/wc/drake/tools/workspace/default.bzl:236:32: in add_default_repositories
/Users/wc/drake/tools/workspace/rules_python/repository.bzl:12:19: in rules_python_repository
/Users/wc/drake/tools/workspace/github.bzl:77:25: in github_archive
Repository rule _github_archive_real defined at:
/Users/wc/drake/tools/workspace/github.bzl:98:39: in <toplevel>
ERROR: no such package '#cc//': Not a regular file: /private/var/tmp/_bazel_wc/ecfb0aaf3c5988894c5be550fe9d5e24/external/local_config_cc/wrapped_clang
INFO: Elapsed time: 1.605s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
currently loading: examples/acrobot ... (3 packages

ansible-container docker.errors.DockerException: Error while fetching server API version

I am trying to build a container using ansible-container module on my Mac and running into the following issue.
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible-container build --roles-path=/Users/karthikjayaraman/roles
Building Docker Engine context...
Starting Docker build of Ansible Container Conductor image (please be patient)...
Parsing conductor CLI args.
Dockerâ„¢ daemon integration engine loaded. Build starting. project=infrastructure
Building service... project=infrastructure service=mdcsat
Traceback (most recent call last):
File "/usr/bin/conductor", line 11, in <module>
load_entry_point('ansible-container', 'console_scripts', 'conductor')()
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/cli.py", line 399, in conductor_commandline
**params)
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/core.py", line 700, in conductorcmd_build
cur_image_id = engine.get_image_id_by_tag(service['from'])
File "/_ansible/container/docker/engine.py", line 549, in get_image_id_by_tag
image = self.client.images.get(tag)
File "/_ansible/container/docker/engine.py", line 164, in client
self._client = docker.from_env(version='auto', timeout=timeout)
File "/usr/lib/python2.7/site-packages/docker/client.py", line 80, in from_env
**kwargs_from_env(**kwargs))
File "/usr/lib/python2.7/site-packages/docker/client.py", line 37, in __init__
self.api = APIClient(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 147, in __init__
self._version = self._retrieve_server_version()
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 174, in _retrieve_server_version
'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))
Conductor terminated. Cleaning up. command_rc=1 conductor_id=6a4f7bcb46a33b8053d22af2ecc17abaa84abddf99f80f133b921546d36c76fc save_container=False
ERROR Conductor exited with status 1
The build numbers of the components are as follows:
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible --version
ansible 2.6.1
config file = /Users/karthikjayaraman/mdc/mdc/tools/infrastructure/ansible.cfg
configured module search path = [u'/Users/karthikjayaraman/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Python/2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ docker --version
Docker version 18.03.1-ce, build 9ee9f40
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ ansible-container version
Ansible Container, version 0.9.2
Docker on my Mac is installed and running well.
Karthiks-MacBook-Pro:infrastructure karthikjayaraman$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Any help appreciated !.
Are you sure, you added your user account to the docker group? (your = account you run ansible-container under)
See here: https://docs.docker.com/engine/installation/linux/linux-postinstall/

Pytest fails on Travis: cannot find main package

I recently made a large swath of changes to a Python 3 project on Github, largely documentation and docstrings.
The tests pass locally, but when I push the branch to Github, Travis CI fails:
$ pytest
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.5/lib/python3.5/site-packages/_pytest/config.py", line 342, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('/home/travis/build/scossu/lakesuperior')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.5/lib/python3.5/site-packages/_pytest/config.py", line 373, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('/home/travis/build/scossu/lakesuperior/conftest.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.5/lib/python3.5/site-packages/_pytest/config.py", line 379, in _importconftest
mod = conftestpath.pyimport()
File "/home/travis/virtualenv/python3.5.5/lib/python3.5/site-packages/py/_path/local.py", line 668, in pyimport
__import__(modname)
File "/home/travis/virtualenv/python3.5.5/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 212, in load_module
py.builtin.exec_(co, mod.__dict__)
File "/home/travis/build/scossu/lakesuperior/conftest.py", line 6, in <module>
from lakesuperior.config_parser import test_config
ImportError: No module named 'lakesuperior.config_parser'
ERROR: could not load /home/travis/build/scossu/lakesuperior/conftest.py
The command "pytest" exited with 4.
lakesuperior is the main application package.
My .travis.yml:
language: python
python:
- "3.5"
- "3.6"
install:
- pip install -r requirements.txt
- coilmq&
script:
- pytest tests
The only thing that I think may have affected the import issue is that I added some __init__.py files to subpackages in order for Sphinx to discover API docs. I am not sure how that may have messed up CI though.
I verified that the previous commit passes all tests as it used to.
Has anybody encountered this scenario before? Any hints?
Thanks.
I recently had the same issue. I fixed it by removing the __init__.py file from the top level directory. See here.

Running Gramex on new Ubuntu 16.04 Installation

I'm having trouble running gramex in Ubuntu 16.04.
Running it inside docker works fine, which leads me to suspect that I'm missing some dependency, but can't seem to figure out which one.
This is the error that I get, any ideas?
INFO 22-Mar 11:33:21 install Gramex 1.31.0 | guide --browser=/welcome | /gramex/apps/guide | Python 3.6.4 |Anaconda, Inc.| (default, Mar 13 2018, 01:15:57) [GCC 7.2.0]
WARNING 22-Mar 11:33:21 config Missing config: /.config/gramexdata/mail/gramexmail.yaml
WARNING 22-Mar 11:33:21 watcher watch directory /.config/gramexdata/mail does not exist
INFO 22-Mar 11:33:21 config No config found: /.config/gramexdata/mail/gramexmail.yaml
Traceback (most recent call last):
File "/anaconda3/envs/gramex/bin/gramex", line 11, in <module>
sys.exit(commandline())
File "/anaconda3/envs/gramex/lib/python3.6/site-packages/gramex/__init__.py", line 172, in commandline
callback(**kwargs)
File "anaconda3/envs/gramex/lib/python3.6/site-packages/gramex/install.py", line 539, in run
gramex.init(cmd=AttrDict(app=app_config['run']))
File "anaconda3/envs/gramex/lib/python3.6/site-packages/gramex/__init__.py", line 279, in init
callback = getattr(services, key)(conf[key])
File "anaconda3/envs/gramex/lib/python3.6/site-packages/gramex/services/__init__.py", line 133, in app
if ioloop._running:
AttributeError: 'AsyncIOMainLoop' object has no attribute '_running'
Gramex 1.31 is not compatible with Tornado 5.0. This will be resolved in Gramex 1.32, which is due on 31 Mar 2018, and is tracked here

Resources