bad argument #1 to '?' in function 'require' ERROR

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ObesePlant
Prole
Posts: 1
Joined: Wed Oct 24, 2018 3:23 pm

bad argument #1 to '?' in function 'require' ERROR

Post by ObesePlant »

Hi guys.

First off, some details:
OS: Mac Sierra
LOVE2D version: 11.1

The console outputs the following error to the screen:

Code: Select all

Error

bad argument #1 to '?' (string expected, got nil)


Traceback

[C]: at 0x010f045a10
[C]: in function 'require'
main.lua:22: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
It seems that this is outputted in a random fashion. I have other versions of the code (that do not change significantly) in the same directory and with the same push.lua latest versions, yet these other versions work too. I also tried to make another test from scratch and when I try to require 'push', I get the same error.

And yes, push.lua is in the same directory as main.lua

Here is a snippet of the code:

Code: Select all

push = require 'push'

-- classic OOP class library
Class = require 'class'

-- bird class we've written
require 'Bird'
I suspect it's something dumb, but why would other versions with this exact same code work? they only differ in a change in some irrelevant functions or external classes.
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: bad argument #1 to '?' in function 'require' ERROR

Post by D0NM »

Does your folder name contain any non ASCI characters?
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
xNick1
Party member
Posts: 267
Joined: Wed Jun 15, 2016 8:27 am
Location: Rome, Italy

Re: bad argument #1 to '?' in function 'require' ERROR

Post by xNick1 »

Try with require("whatever"), that's how I do it and it works hehe
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: bad argument #1 to '?' in function 'require' ERROR

Post by grump »

Check the encoding of the file you try to require. I suspect it has been saved with an encoding that is not supported. Lua files should be saved as UTF-8.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 75 guests