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

Problem in shell scripts, docker error while building #163

Open
sudhz opened this issue Apr 22, 2024 · 0 comments
Open

Problem in shell scripts, docker error while building #163

sudhz opened this issue Apr 22, 2024 · 0 comments

Comments

@sudhz
Copy link

sudhz commented Apr 22, 2024

 => ERROR [frontend 16/16] RUN make frontend                                                                                                                                                                                   33.9s 
------
 > [frontend 16/16] RUN make frontend:
#0 1.033 yarn install
#0 1.321 yarn install v1.22.5
#0 1.605 [1/4] Resolving packages...
#0 2.405 success Already up-to-date.
#0 2.424 Done in 1.11s.
#0 2.473 cd docs/openapi && yarn install
#0 2.756 yarn install v1.22.5
#0 2.834 warning package.json: License should be a valid SPDX license expression
#0 2.985 warning mcaptcha@0.1.0: License should be a valid SPDX license expression
#0 2.990 [1/4] Resolving packages...
#0 3.535 success Already up-to-date.
#0 3.551 Done in 0.81s.
#0 3.605 cd docs/openapi && yarn build
#0 3.968 yarn run v1.22.5
#0 4.157 warning package.json: License should be a valid SPDX license expression
#0 4.226 $ swagger-cli bundle openapi.yaml --outfile dist/openapi.yaml --type yaml
#0 4.923 Created dist/openapi.yaml from openapi.yaml
#0 4.941 Done in 0.99s.
#0 4.963 yarn install
#0 5.341 yarn install v1.22.5
#0 5.640 [1/4] Resolving packages...
#0 6.494 success Already up-to-date.
#0 6.514 Done in 1.19s.
#0 6.584 yarn build
#0 6.977 yarn run v1.22.5
#0 7.110 $ webpack --mode production
#0 24.77 Browserslist: caniuse-lite is outdated. Please run:
#0 24.77   npx browserslist@latest --update-db
#0 24.77   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
#0 25.57 assets by path *.js 25.7 KiB
#0 25.57   asset bundle.js 17.6 KiB [emitted] [minimized] (name: bundle)
#0 25.57   asset bench.js 5.83 KiB [emitted] [minimized] (name: bench)
#0 25.57   asset verificationWidget.js 2.28 KiB [emitted] [minimized] (name: verificationWidget)
#0 25.57 asset d31bd4308c685c96d507.module.wasm 72 KiB [emitted] [immutable] (auxiliary name: bench)
#0 25.57 asset verificationWidget.css 1.55 KiB [emitted] [minimized] (name: verificationWidget)
#0 25.57 Entrypoint bundle 17.6 KiB = bundle.js
#0 25.57 Entrypoint verificationWidget 3.83 KiB = verificationWidget.css 1.55 KiB verificationWidget.js 2.28 KiB
#0 25.57 Entrypoint bench 5.83 KiB (72 KiB) = bench.js 1 auxiliary asset
#0 25.57 orphan modules 55.8 KiB (javascript) 937 bytes (runtime) [orphan] 59 modules
#0 25.57 runtime modules 4.72 KiB 8 modules
#0 25.57 cacheable modules 63.2 KiB (javascript) 1.59 KiB (css/mini-extract) 72 KiB (webassembly)
#0 25.57   javascript modules 63.2 KiB
#0 25.57     modules by path ./templates/ 57.9 KiB
#0 25.57       modules by path ./templates/widget/ 7.46 KiB 3 modules
#0 25.57       ./templates/index.ts + 47 modules 49.9 KiB [built] [code generated]
#0 25.57       ./templates/logger.ts 529 bytes [built] [code generated]
#0 25.57     modules by path ./node_modules/@mcaptcha/ 5.31 KiB
#0 25.57       ./node_modules/@mcaptcha/pow_sha256-polyfill/dist/index.js 1.15 KiB [built] [code generated]
#0 25.57       ./node_modules/@mcaptcha/pow-wasm/pow_wasm_bg.js 4.16 KiB [built] [code generated]
#0 25.57   css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].use[2]!./templates/widget/main.scss 1.59 KiB [built] [code generated]
#0 25.57   ./node_modules/@mcaptcha/pow-wasm/pow_wasm_bg.wasm 50 bytes (javascript) 72 KiB (webassembly) [built] [code generated]
#0 25.57 webpack 5.58.1 compiled successfully in 15557 ms
#0 25.66 Done in 18.69s.
#0 26.08 yarn run v1.22.5
#0 26.17 $ /src/node_modules/.bin/sass -s compressed templates/main.scss ./static/cache/bundle/css/main.css
#0 27.48 Done in 1.42s.
#0 27.84 yarn run v1.22.5
#0 27.97 $ /src/node_modules/.bin/sass -s compressed templates/mobile.scss ./static/cache/bundle/css/mobile.css
#0 28.88 Done in 1.05s.
#0 29.24 yarn run v1.22.5
#0 29.39 $ /src/node_modules/.bin/sass -s compressed templates/widget/main.scss ./static/cache/bundle/css/widget.css
#0 30.27 Done in 1.04s.
#0 30.28 make: ./scripts/librejs.sh: Command not found
#0 30.28 make: *** [Makefile:49: frontend] Error 127
------
failed to solve: executor failed running [/bin/sh -c make frontend]: exit code: 2

When i try to build the image using docker build from my local repo then i am getting this error. It appears that the script file contains additional characters such as \r (carriage return) and \t (tab) at the end of each line. These characters are not visible when viewing the script in a text editor, but they are interpreted as part of the script when it is executed, causing syntax errors. I used sed to display each line of the file with non-printable characters represented as \r, \n, etc.

.......
	sed -n l ./scripts/librejs.sh
	#!/bin/bash\r$
	\r$
	# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@bats\
	ense.net>\r$
	#\r$
	# SPDX-License-Identifier: AGPL-3.0-or-later\r$
	\r$
	set -Eeuo pipefail\r$
	trap cleanup SIGINT SIGTERM ERR EXIT\r$
	\r$
	readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0\
	]}")))\r$
	readonly DIST=$PROJECT_ROOT/static/cache/bundle/\r$
	readonly SOURCE="// @source https://github.com/mCaptcha/mCaptcha"\r$
	readonly LICENSE_END="// @license-end"\r$
	\r$
	source $PROJECT_ROOT/scripts/lib.sh\r$
	\r$
	print_license_msg() {\r$
	\tmsg "${GREEN}- Applying $1 on  $(get_file_name $2)"\r$
	}\r$
	\r$
	apply_agpl() {\r$
	\tprint_license_msg "AGPL" $1\r$
	\tlocal AGPL='// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270\
	c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0'\r$
	\techo $AGPL >> $1\r$
	}\r$
	\r$
	apply_x11() {\r$
	\tprint_license_msg "X11" $1\r$
	\tlocal MIT='// @license magnet:?xt=urn:btih:5305d91886084f776adcf575\
	09a648432709a7c7&dn=x11.txt X11'\r$
	\techo $MIT >> $1\r$
	}\r$
	\r$
	apply_apache() {\r$
	\tprint_license_msg "APACHE" $1\r$
	\tlocal APACHE='// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93\
	c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0'\r$
	\techo $APACHE >> $1\r$
	}\r$
	\r$
	setup_colors\r$
	\r$
	msg "${BLUE}[*] LibreJS processor running"\r$
	\r$
	for file in $(find $DIST  -type f -a -name "*.js")\r$
	do\r$
	\tcontents=""\r$
	\tcp $file $file.librejs\r$
	\t: > $file\r$
	\r$
	\tname=$(get_file_name $file)\r$
	\tcase $name in\r$
	\t\t"bundle.js")\r$
	\t\t\tapply_agpl $file\r$
	\t\t\t;;\r$
	\t\t"verificationWidget.js" | "bench.js")\r$
	\t\t\tapply_x11 $file\r$
	\t\t\tapply_apache $file\r$
	\t\t\t;;\r$
	\t\t*)\r$
	\t\t\tmsg "${RED}- [!] License not configured for $name. Applying def\
	ault license"\r$
	\t\t\tapply_agpl $file\r$
	\t\t\t;;\r$
	\tesac\r$
	\r$
	\techo $SOURCE >> $file\r$
	\tcat $file.librejs >> $file\r$
	\trm $file.librejs\r$
	\techo $LICENSE_END >> $file\r$
	done\r$
	make: ./scripts/librejs.sh: No such file or directory
	make: *** [Makefile:139: frontend] Error 127

mCaptcha/Makefile

Lines 127 to 144 in 9922c23

frontend: ## Build frontend
$(call frontend_env)
cd $(OPENAPI) && yarn build
yarn install
@-rm -rf $(BUNDLE)
@-mkdir $(BUNDLE)
yarn build
@yarn run sass -s \
compressed templates/main.scss \
./static/cache/bundle/css/main.css
@yarn run sass -s \
compressed templates/mobile.scss \
./static/cache/bundle/css/mobile.css
@yarn run sass -s \
compressed templates/widget/main.scss \
./static/cache/bundle/css/widget.css
@./scripts/librejs.sh
@./scripts/cachebust.sh

I replaced this part of the Makefile with the following:

frontend: ## Build frontend
	$(call frontend_env)
	cd $(OPENAPI) && yarn build
	yarn install
	@-rm -rf $(BUNDLE)
	@-mkdir $(BUNDLE)
	yarn build
	@yarn run sass -s \
		compressed templates/main.scss  \
		./static/cache/bundle/css/main.css
	@yarn run sass -s \
		compressed templates/mobile.scss  \
		./static/cache/bundle/css/mobile.css
	@yarn run sass -s \
		compressed templates/widget/main.scss  \
		./static/cache/bundle/css/widget.css
	tr -d '\r\t' < ./scripts/librejs.sh > temp && mv temp ./scripts/librejs.sh
	tr -d '\r\t' < ./scripts/lib.sh > temp && mv temp ./scripts/lib.sh
	tr -d '\r\t' < ./scripts/cachebust.sh > temp && mv temp ./scripts/cachebust.sh
	tr -d '\r\t' < ./scripts/integration.sh > temp && mv temp ./scripts/integration.sh
	tr -d '\r\t' < ./scripts/publish.sh > temp && mv temp ./scripts/publish.sh
	tr -d '\r\t' < ./scripts/tests.sh > temp && mv temp ./scripts/tests.sh
	@bash ./scripts/librejs.sh
	@bash ./scripts/cachebust.sh

And there are no errors while building this part.

Information about the environment:

$ rustc --version
rustc 1.77.2 (25ef9e3d8 2024-04-09)

$ make --version
GNU Make 4.4.1
Built for Windows32
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ echo $SHELL
/usr/bin/bash

$ uname -a
MINGW64_NT-10.0-19045 ********2ng31r 3.4.9-be826601.x86_64 2023-09-07 12:36 UTC x86_64 Msys

Is anyone else facing the same issue?

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

1 participant