# "require set " error

**URL:** <https://forums.sketchup.com/t/require-set-error/49277>\
**Category:** Ruby API\
**Tags:** sketchup\
**Created:** [July 31, 2017, 2:43pm UTC](https://forums.sketchup.com/t/require-set-error/49277 "2017-07-31T14:43:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CharellkingQu](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@CharellkingQu](https://forums.sketchup.com/u/CharellkingQu)\
**Post date:** [July 31, 2017, 2:43pm UTC](https://forums.sketchup.com/t/require-set-error/49277/1 "2017-07-31T14:43:36Z")

</div>

```ruby
# coding: utf-8

require 'sketchup'
require 'set'

Encoding.default_external='utf-8'

```

when i install sketchup into the directory with chinese character, the sketchup plugin loads with errors when i require set. I guess the set library is in the installation’s directory. but the path has other characters not ascill. so is it a bug for sketchup?

```nohighlight
Error: #<Encoding::UndefinedConversionError: "\xAF\xE4" from GBK to UTF-8>
c:/users/vic/appdata/roaming/sketchup/sketchup 2015/sketchup/plugins/sk_building_client.rbs:4:in `require'
c:/users/vic/appdata/roaming/sketchup/sketchup 2015/sketchup/plugins/sk_building_client.rbs:4:in `<main>'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `eval'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `require'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `block in require_all'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `each'
C:/软件/Sketchup_2015/Tools/sketchup.rb:85:in `require_all'
<main>:in `<main>'
SketchUp:1:in `eval'

```

---

<div class="post-metadata">

**Author:** ![CharellkingQu](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@CharellkingQu](https://forums.sketchup.com/u/CharellkingQu)\
**Post date:** [July 31, 2017, 2:48pm UTC](https://forums.sketchup.com/t/require-set-error/49277/2 "2017-07-31T14:48:00Z")

</div>

When i replace the “Set” with “Sketchup::Set”, i don’t require set in standard library. but when i require ‘logger’, it also has the same problem. what can i do?

---

<div class="post-metadata">

**Author:** ![MSP\_Greg](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/msp_greg/32/206066_2.png) [@MSP\_Greg](https://forums.sketchup.com/u/MSP_Greg)\
**Post date:** [August 1, 2017, 2:44am UTC](https://forums.sketchup.com/t/require-set-error/49277/3 "2017-08-01T02:44:45Z")

</div>

Before any requires, try adding

```ruby
$LOAD_PATH.map! { |d| d.dup.force_encoding('UTF-8') }

```

You may have to repeat it if the $LOAD\_PATH array changes. I believe it’s a Ruby issue. SU 2017 also seems to have the same issue, the above fix works for it. Don’t have SU 2015 installed…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [October 31, 2017, 6:45pm UTC](https://forums.sketchup.com/t/require-set-error/49277/4 "2017-10-31T18:45:02Z")

</div>

Closed on October 31, 2017, 6:45pm UTC

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
