Error compiling publishingtools
V doctor:
OS: linux, Linux version 5.15.23-2-lts (linux-lts@archlinux) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.38) #1 SMP Tue, 15 Feb 2022 12:04:53 +0000
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
CC version: cc (GCC) 11.2.0
getwd: /home/johndoe/opt/github/crystaluniverse/publishtools
vmodules: /home/johndoe/.vmodules
vroot: /home/johndoe/opt/github/vlang/v
vexe: /home/johndoe/opt/github/vlang/v/v
vexe mtime: 2022-02-17 09:17:41
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 901a4d8.4f90399
Git version: git version 2.35.1
Git vroot status: weekly.2022.07-24-g4f903999
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 3654d6a8
What did you do?
v -g -o vdbg cmd/v && vdbg /home/johndoe/.vmodules/despiegk/crystallib/installers/website_run_build.v
module installers
import publisher_config
import process
// import path
import json
import os
pub fn website_develop( names []string) ? {
mut conf := publisher_config.get()?
for mut sc in conf.sites_get(names) {
mut repo := sc.repo_get()
println(' - start website: $repo.path()')
process.execute_interactive('$repo.path()/run') ?
}
}
fn rewrite_config(path string, shortname string) {
println(' >> REWRITE CONFIG: $path $shortname')
}
pub fn website_build(use_prefix bool, names []string) ? {
// save new config file
// publisher_config.save('') ?
mut conf := publisher_config.get()?
for mut sc in conf.sites_get(names) {
mut repo := sc.repo_get()
if sc.cat != publisher_config.SiteCat.web {
continue
}
println(' - build website: $repo.path_get()')
mut isgridsome := true
mut vuejs := true
if !os.exists('$repo.path_get()/gridsome.config.js'){
isgridsome = false
}
if !os.exists('$repo.path_get()/vue.config.js'){
vuejs = false
}
if isgridsome{
process.execute_stdout('sed -i "s/pathPrefix.*//" $repo.path_get()/gridsome.config.js') ?
}else if vuejs{
process.execute_stdout('sed -i "s/publicPath:.*//" $repo.path_get()/vue.config.js') ?
}
if use_prefix {
if isgridsome{
process.execute_stdout('sed -i "s/plugins: \\\[/pathPrefix: \\\"$sc.prefix\\\",\\n\\tplugins: \\\[/g" $repo.path_get()/gridsome.config.js') ?
}else if vuejs{
process.execute_stdout('sed -i "s/configureWebpack: {/publicPath: \\\"\\/$sc.prefix\\\",\\n\configureWebpack: {/g" $repo.path_get()/vue.config.js') ?
}
}
process.execute_stdout('$repo.path_get()/build') or {
if isgridsome{
process.execute_stdout('cd $repo.path_get()/ && git checkout gridsome.config.js') ?
}else if vuejs{
process.execute_stdout('cd $repo.path_get()/ && git checkout vue.config.js') ?
}
}
if isgridsome{
process.execute_stdout('cd $repo.path_get()/ && git checkout gridsome.config.js') ?
}else if vuejs{
process.execute_stdout('cd $repo.path_get()/ && git checkout vue.config.js') ?
}
// Write config files
println("- Write config file for site: $sc.name to $conf.publish.paths.publish")
the_config := json.encode_pretty(sc.raw)
os.write_file('$conf.publish.paths.publish/config_site_'+sc.name+'.json', the_config) ?
}
}
What did you expect to see?
sucees
What did you see instead?
/home/johndoe/.vmodules/despiegk/crystallib/installers/website_run_build.v:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
1 | module installers
| ^
2 |
3 | import publisher_config
If you want just to check, that a module can compile, you can use:
v -shared /home/johndoe/.vmodules/despiegk/crystallib/installers/ - it will produce a shared library.
v -check -shared /home/johndoe/.vmodules/despiegk/crystallib/installers/ also works and is faster, but will not try to compile fully - it will just check that there are no syntax and checker errors in that module.
To get an executable, you need to have a .v file that contains a fn main() { function, and that is in a file that has module main at the top (or no module line at all).
Files that have module installers at the top, are part of a module installers, not module main.

suggest to close